#include <bits/stdc++.h>
#define int unsigned
#define lop(n,s,e) for (int n = s; n <= e; ++n)
#define ril(n,s,e) for (int n = s; n >= e; --n)
namespace IO {
template<typename T>
inline T &read(T &x) {
x = 0;
T f = 1;
int ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (!(ch ^ 45)) f = -1;
for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
x *= f;
return x;
}
template<typename First, typename ...Args>
inline void read(First &first, Args &...args) {
read(first);
read(args...);
}
class ReadClass {
public:
ReadClass() = default;
template<typename T>
inline ReadClass &operator()(T &x) {
read(x);
return *this;
}
template<typename ...Args>
inline ReadClass &operator()(Args &...args) {
read(args...);
return *this;
}
template<typename Element>
inline ReadClass &array(Element *p, size_t start, size_t end) {
for (size_t i = start; i < end; ++i) {
read(p[i]);
}
return *this;
}
};
template<typename T>
inline void write(T x) {
if (x < 0) putchar(45), x = -x;
if (x > 9) write(x / 10);
putchar(x % 10 ^ 48);
}
class WriteClass {
public:
WriteClass() = default;
template<typename T>
inline WriteClass &operator()(const T &x, const char c = ' ') {
write(x);
putchar(c);
return *this;
}
inline WriteClass &p(const char c) {
putchar(c);
return *this;
}
inline WriteClass &e() {
putchar(10);
return *this;
}
inline WriteClass &s() {
putchar(32);
return *this;
}
inline WriteClass &t() {
putchar(9);
return *this;
}
};
inline void endl() { putchar(10); }
inline void space() { putchar(32); }
inline void tab() { putchar(9); }
ReadClass Read = ReadClass();
WriteClass Write = WriteClass();
#define endl endl()
#define space space()
#define tab tab()
#define cout(v) cout << v
}
using namespace IO;
using namespace std;
template<class T>
using minheap = priority_queue<T, vector<T>, greater<>>;
template<class T>
using maxheap = priority_queue<T, vector<T>, less<>>;
const int idx[] = {44, 43, 42, 41, 34, 33, 32, 31,
24, 23, 22, 21, 14, 13, 12, 11};
bool m;
int s, t;
int pre[1 << 16];
queue<int> que;
bitset<1 << 16> vis;
stack<int> output;
void swap(int &x, int a, int b) {
m = x & (1 << (16 - a));
x &= ~(1 << (16 - a));
x |= (1 << (16 - a)) & (x & (1 << (16 - b)));
x &= ~(1 << (16 - b));
x |= m << (16 - b);
}
bool getch() {
int c = getchar();
while (c != '0' && c != '1') {
c = getchar();
}
return c == '1';
}
void solve() {
int n;
vis[s] = true;
que.emplace(s);
while (!que.empty()) {
const int e = que.front();
que.pop();
if (e == t) break;
lop (i, 1, 16) {
if ((i & 0b11) != 1) {
n = e;
swap(n, i, i - 1);
if (!vis[n]) {
vis[n] = true;
pre[n] = e;
que.emplace(n);
}
}
if (i & 0b11) {
n = e;
swap(n, i, i + 1);
if (!vis[n]) {
vis[n] = true;
pre[n] = e;
que.emplace(n);
}
}
if (i > 4) {
n = e;
swap(n, i, i - 4);
if (!vis[n]) {
vis[n] = true;
pre[n] = e;
que.emplace(n);
}
}
if (i < 12) {
n = e;
swap(n, i, i + 4);
if (!vis[n]) {
vis[n] = true;
pre[n] = e;
que.emplace(n);
}
}
}
}
}
int lg2(int x) {
int res = -1;
while (x) x >>= 1, res++;
return res;
}
signed main() {
lop (i, 1, 16) s |= getch() << (16 - i);
lop (i, 1, 16) t |= getch() << (16 - i);
solve();
int ans = -1;
for (int i = t; i; i = pre[i]) {
ans++;
output.emplace(i);
}
write(ans), endl;
int last = output.top(), now, change;
output.pop();
while (!output.empty()) {
now = output.top();
output.pop();
change = last ^ now;
write(idx[lg2(change & last)]), write(idx[lg2(change & now)]), endl;
last = now;
}
return 0;
}