import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext())
        {
            int radix = scanner.nextInt();
            if (radix==0)
                break;
            String s1 = scanner.next();
            String s2 = scanner.next();

            BigInteger n1 = new BigInteger(s1);
            BigInteger n2 = new BigInteger(s2);

            System.out.println(n1.add(n2).toString(radix));
        }
    }
}