Problem:
Score : 2400 points

Problem Statement

Takahashi and Aoki love calculating things, so they will play with numbers now.

First, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y.
Then, they will enjoy themselves by repeating the following operation K times:

Compute the bitwise AND of the number currently kept by Takahashi and the number currently kept by Aoki. Let Z be the result.

Then, add Z to both of the numbers kept by Takahashi and Aoki.

However, it turns out that even for the two math maniacs this is just too much work.
Could you find the number that would be kept by Takahashi and the one that would be kept by Aoki eventually?

Note that input and output are done in binary.
Especially, X and Y are given as strings S and T of length N and M consisting of 0 and 1, respectively, whose initial characters are guaranteed to be 1.

Constraints

1 ≤ K ≤ 10^6

1 ≤ N,M ≤ 10^6

The initial characters of S and T are 1.

Input

Input is given from Standard Input in the following format:

N M K
S
T

Output

In the first line, print the number that would be kept by Takahashi eventually; in the second line, print the number that would be kept by Aoki eventually.
Those numbers should be represented in binary and printed as strings consisting of 0 and 1 that begin with 1.

Sample Input 1

2 3 3
11
101

Sample Output 1

10000
10010

The values of X and Y after each operation are as follows:

After the first operation: (X,Y)=(4,6).

After the second operation: (X,Y)=(8,10).

After the third operation: (X,Y)=(16,18).

Sample Input 2

5 8 3
10101
10101001

Sample Output 2

100000
10110100

Sample Input 3

10 10 10
1100110011
1011001101

Sample Output 3

10000100000010001000
10000100000000100010

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)



using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        int n = int.Parse(input.Split(' ')[0]);
        int m = int.Parse(input.Split(' ')[1]);
        int k = int.Parse(input.Split(' ')[2]);
        string s = Console.ReadLine();
        string t = Console.ReadLine();

        long ss = 0;
        long tt = 0;
        
        foreach (char c in s.Reverse())
        {
            ss = ss * 2 + int.Parse("0" + c);
        }
        foreach (char c in t.Reverse())
        {
            tt = tt * 2 + int.Parse("0" + c);
        }

        for (int i = 0; i < k; i++)
        {
            long aa = ss & tt;
            ss += aa;
            tt += aa;
        }

        Console.WriteLine(Convert.ToString(ss, 2));
        Console.WriteLine(Convert.ToString(tt, 2));

        Console.WriteLine(Convert.ToString(654654654654654, 2));
        Console.WriteLine(Convert.ToString(6546546556654654654, 2));
        Console.WriteLine(Convert.ToString(4655656556454654654, 2));

        //List<int> values = new List<int>(Console.ReadLine().Split(' ').Select(s => int.Parse(s)));
        //List<int> values = new List<int>();
        //for (int i = 0; i < n; i++)
        //{
        //    values.Add(int.Parse(Console.ReadLine()));
        //}
        //int t = 0;
        //int x = 0;
        //int y = 0;

        //for (int i = 0; i < n; i++)
        //{
        //    string s = Console.ReadLine();
        //    int nextt = int.Parse(s.Split(' ')[0]);
        //    int nextx = int.Parse(s.Split(' ')[1]);
        //    int nexty = int.Parse(s.Split(' ')[2]);
        //    int difft = nextt - t;
        //    int diffx = Math.Abs(nextx - x);
        //    int diffy = Math.Abs(nexty - y);
        //    int diffxy = diffx + diffy;
        //    difft -= diffxy;
        //    if(difft<0)
        //    {
        //        Console.WriteLine("No");
        //        return;
        //    }
        //    if(difft%2==0)
        //    {
        //        //Console.WriteLine("Yes");
        //    }
        //    else
        //    {
        //        Console.WriteLine("No");
        //        return;
        //    }
        //    t = nextt;
        //    x = nextx;
        //    y = nexty;
        //}
        //Console.WriteLine("Yes");


        //int n = int.Parse(s.Split(' ')[0]);
        //int y = int.Parse(s.Split(' ')[1]) / 1000;


        //for (int aa = 0; aa <= n; aa++)
        //{
        //    for (int bb = 0; bb <= n - aa; bb++)
        //    {
        //        if (aa * 9 + bb * 4 + n == y)
        //        {
        //            Console.WriteLine(aa + " " + bb + " " + (n - aa - bb));
        //            return;
        //        }
        //    }
        //}


        //Console.WriteLine((s.Length == 0) ? "YES" : "NO");


        //Console.WriteLine("-1 -1 -1");
        Console.ReadLine();
    }
}