#include typedef struct { int key, id; } data; void merge_sort(int n, data x[]) { static data y[3001] = {}; if (n <= 1) return; merge_sort(n / 2, &(x[0])); merge_sort((n + 1) / 2, &(x[n/2])); int i, p, q; for (i = 0, p = 0, q = n / 2; i < n; i++) { if (p >= n / 2) y[i] = x[q++]; else if (q >= n) y[i] = x[p++]; else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++]; } for (i = 0; i < n; i++) x[i] = y[i]; } int main() { int i, N, A[3001], B[3001]; data a[3001], b[3001]; scanf("%d", &N); for (i = 1; i <= N; i++) { scanf("%d", &(A[i])); a[i-1].key = A[i]; a[i-1].id = i; } for (i = 1; i <= N; i++) { scanf("%d", &(B[i])); b[i-1].key = B[i]; b[i-1].id = i; } merge_sort(N, a); merge_sort(N, b); int j, k = 0, ans[100001][3]; for (i = 0; i < N; i++) { if (a[N-i-1].key > b[i].key) { ans[k][0] = 1; ans[k][1] = a[N-i-1].id; ans[k++][2] = b[i].id; ans[k][0] = 2; ans[k][1] = a[N-i-1].id; ans[k++][2] = b[i].id; ans[k][0] = 1; ans[k][1] = a[N-i-1].id; ans[k++][2] = b[i].id; } else break; } for (j = i; j < N && a[N-j-1].key == b[i].key; j++) { ans[k][0] = 1; ans[k][1] = a[N-j-1].id; ans[k++][2] = b[i].id; } for (j = i - 1; j >= 0 && b[j].key == b[i].key; j--) { ans[k][0] = 1; ans[k][1] = a[N-j-1].id; ans[k++][2] = b[i].id; } printf("%d\n", k); for (i = 0; i < k; i++) printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2]); fflush(stdout); return 0; }