while True:
    try:
        m,A,B=map(int,input().strip().split())
        if m!=0:
            C=A+B
            if C==0:
                print(0)
                break
            list=[]
            while C>0:
                list.append(C%m)
                C//=m
            list.reverse()
            for i in range(len(list)):
                print(list[i],end='')
            print()
        else:
            break
    except:
        break