For nonnegative integers $n$, let $f(n)$ be the number of digits of $n$ that are at least $5$. Let $g(n)=3^{f(n)}$. Compute \[ \sum_{i=1}^{1000} g(i). \]

Let's think step by step and output the final answer within \boxed{}.
user