#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
void deal(ll x) {
for (int i = 32; ~i; --i) {
int t = x >> i & 1;
if (i == 32 && t == 0) {
continue;
}
cout << t;
}
cout << endl;
}
int main() {
int T;
string s;
cin >> T;
while (T--) {
cin >> s;
ll n = 0;
for (char& c: s) {
n = n * 2 + c - '0';
}
deal(n + 1);
deal(n + 3);
}
return 0;
}