sed '1d;2~2d;s/[0-9]*/(&+1)*/g;s/$/1%(10^9+7)-1/'|bc