Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
flist[0]=1
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  elif p<=x+n-1:
    ans=0
  else:
    x=x*pow(d,p-2,p)%p
    ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % p
    elif y % 2 == 0 : return power(x, y//2)**2 % p
    else            : return power(x, y//2)**2 * x % p
    
factorial_list=[1 for i in range(p)]
for i in range(1,p):
    factorial_list[i]=factorial_list[i-1]*i%p
    
inv_list=[1 for i in range(p)]
inv_list[-1]=factorial_list[-1]
for i in range(p-1,1,-1):
    inv_list[i-1]=inv_list[i]*i%p
    
for i in range(q):
    x,d,n=(int(i) for i in input().split())
    if d%p==0:
        ans=power(x,n)
        print(ans%p)
    elif x<=p*d<=x+(n-1)*d or x==0:
        print(0)
    else:
        x=x*power(d,p-2)%p
        ans=factorial_list[x+n-1]*inv_list[x-1]*power(d,n)
        print(ans%p)
        


Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % p
    elif y % 2 == 0 : return power(x, y//2)**2 % p
    else            : return power(x, y//2)**2 * x % p
    
factorial_list=[1 for i in range(p)]
for i in range(1,p):
    factorial_list[i]=factorial_list[i-1]*i%p
    
inv_list=[1 for i in range(p)]
inv_list[-1]=factorial_list[-1]
for i in range(p-1,1,-1):
    inv_list[i-1]=inv_list[i]*i%p
    
for i in range(q):
    x,d,n=(int(i) for i in input().split())
    if d%p==0:
        ans=power(x,n)
        print(ans%p)
    elif x<=p*d<=x+(n-1)*d:
        print(0)
    else:
        x=x*power(d,p-2)%p
        ans=factorial_list[x+n-1]*inv_list[x-1]*power(d,n)
        print(ans%p)
        


Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % p
    elif y % 2 == 0 : return power(x, y//2)**2 % p
    else            : return power(x, y//2)**2 * x % p
    
factorial_list=[1 for i in range(p)]
for i in range(1,p):
    factorial_list[i]=factorial_list[i-1]*i%p
    
inv_list=[1 for i in range(p)]
inv_list[-1]=factorial_list[-1]
for i in range(p-1,1,-1):
    inv_list[i-1]=inv_list[i]*i%p
    
for i in range(q):
    x,d,n=(int(i) for i in input().split())
    if d==0:
        ans=power(x,n)
        print(ans%p)
    elif x<=p*d<=x+(n-1)*d:
        print(0)
    else:
        x=x*power(d,p-2)%p
        ans=factorial_list[x+n-1]*inv_list[x-1]*power(d,n)
        print(ans%p)
        

Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % p
    elif y % 2 == 0 : return power(x, y//2)**2 % p
    else            : return power(x, y//2)**2 * x % p
    
factorial_list=[1 for i in range(p)]
for i in range(1,p):
    factorial_list[i]=factorial_list[i-1]*i%p
    
inv_list=[1 for i in range(p)]
inv_list[-1]=factorial_list[-1]
for i in range(p-1,1,-1):
    inv_list[i-1]=inv_list[i]*i%p
    
for i in range(q):
    x,d,n=(int(i) for i in input().split())
    if d==0:
        ans=power(d,p-2)
        print(ans)
    elif x<=p*d<=x+(n-1)*d:
        print(0)
    else:
        x=x*power(d,p-2)%p
        ans=factorial_list[x+n-1]*inv_list[x-1]*power(d,n)
        print(ans%p)
        

Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
q = int(input())

p=1000003
    
factorial_list=[1 for i in range(p)]
for i in range(1,p):
    factorial_list[i]=factorial_list[i-1]*i%p
    
inv_list=[1 for i in range(p)]
inv_list[-1]=factorial_list[-1]
for i in range(p-1,1,-1):
    inv_list[i-1]=inv_list[i]*i%p
    
for i in range(q):
    x,d,n=(int(i) for i in input().split())
    if d==0:
        ans=pow(x,n,p)
        print(ans)
    elif x<=p*d<=x+(n-1)*d:
        print(0)
    else:
        x=x*pow(d,p-2,p)%p
        ans=factorial_list[x+n-1]*inv_list[x-1]*pow(d,n,p)
        print(ans%p)




Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
q = int(input())

p=1000003
    
factorial_list=[1 for i in range(p)]
for i in range(1,p):
    factorial_list[i]=factorial_list[i-1]*i%p
    
inv_list=[1 for i in range(p)]
inv_list[-1]=factorial_list[-1]
for i in range(p-1,1,-1):
    inv_list[i-1]=inv_list[i]*i%p
    
for i in range(q):
    x,d,n=(int(i) for i in input().split())
    if d==0:
        ans=pow(x,n,p)
        print(ans)
    elif x<=p*d<=x+(n-1)*d:
        print(0)
    else:
        x=x*pow(d,p-2,p)%p
        ans=factorial_list[x+n-1]*inv_list[x-1]*pow(d,n,p)
        print(ans%p)




Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

for j in range(q):
  x,d,n=(int(i) for i in input().split())

  cnt=0
  data1=1
  for i in range(p-2):
    cnt+=1
    data1*=d
    data1=data1%p
  data2=(x*data1)%p

  data3=1
  for i in range(n):
    data3*=(data2+i)
    data3=data3%p
  
  for i in range(n):
    data3*=d
    data3=data3%p
    
  print(data3)

Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
q = int(input())

mod=1000003

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

#def power(x, y):
#    if   y == 0     : return 1
#    elif y == 1     : return x % mod
#    elif y % 2 == 0 : return power(x, y//2)**2 % mod
#    else            : return power(x, y//2)**2 * x % mod
def power(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % mod
        x *= x % mod
        n //= 2

    return K * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

for j in range(q):
    x,d,n=(int(i) for i in input().split())  
    xd=div(x, d)
    ans=1
    if mod <= xd+n-1:
        ans=0

    for i in range(n):
        ans=mul(ans,xd+i)
    
    print((power(d,n)*ans)%mod)
  



Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
q = int(input())

mod=1000003

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

#def power(x, y):
#    if   y == 0     : return 1
#    elif y == 1     : return x % mod
#    elif y % 2 == 0 : return power(x, y//2)**2 % mod
#    else            : return power(x, y//2)**2 * x % mod
def power(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

def div(a, b):
    return mul(a, power(b, mod-2))

for j in range(q):
    x,d,n=(int(i) for i in input().split())  
    xd=div(x, d)
    ans=1
    if mod <= xd+n-1:
        ans=0

    for i in range(n):
        ans=mul(ans,xd+i)
    
    print((power(d,n)*ans)%mod)
  



Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
q = int(input())

mod=1000003

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

for j in range(q):
    x,d,n=(int(i) for i in input().split())  
    xd=div(x, d)
    ans=1
    if mod <= xd+n-1:
        ans=0

    for i in range(n):
        ans=mul(ans,xd+i)
    
    print((power(d,n)*ans)%mod)
  



Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
q = int(input())

mod=1000003

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

for j in range(q):
  x,d,n=(int(i) for i in input().split())
  
  xd=div(x, d)

  ans=1
  for i in range(n):
    ans=mul(ans,xd+i)
    
  print((power(d,n)*ans)%mod)
  

Fixed submission:
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)