using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; var xor = a.Aggregate((x, y) => x ^ y); WriteLine(xor == 0 ? 0 : 1); while (true) { if (xor == 0) { var c = NList; var preva = a[c[0] - 1]; a[c[0] - 1] -= c[1]; xor ^= preva ^ a[c[0] - 1]; if (NN != 0) return; } else { for (var i = 0; i < n; ++i) { var xb = Bits(xor); if (xb <= Bits(a[i])) { var k = a[i] - (xor ^ a[i]); if (k < 0) continue; WriteLine($"{i + 1} {k}"); xor ^= a[i] ^ (a[i] - k); a[i] -= k; if (NN != 0) return; break; } } } } } static int Bits(int a) { var ans = 0; while (a > 0) { ++ans; a >>= 1; } return ans; } }