import std.stdio; import std.string; import std.conv; import std.range; import std.algorithm.sorting; ulong[][] solve(int K, int[] A, int[] B, int[] C, int[] D, int[] E, int[] F){ ulong[][] result; auto trunk = E.length.iota.array.sort!((a, b) => E[a] < E[b]); auto tip = A.length.iota.array.sort!((a, b) => A[a] < A[b]); auto middle = C.length.iota.array.sort!((a, b) => C[a] < C[b]); int e = 0; int a = 0; int c = 0; for(int i = 0; i < K; i++){ while(E[trunk[e]] >= A[tip[a]]){ a++; } while(A[tip[a]] >= C[middle[c]]){ c++; } result ~= [tip[a] + 1, middle[c] + 1, middle[c + 1] + 1, trunk[e] + 1]; e++; a++; c += 2; } return result; } void main(){ auto input = readln.chomp.split.to!(int[]); auto N = input[0]; auto K = input[1]; auto A = readln.chomp.split.to!(int[]); auto B = readln.chomp.split.to!(int[]); auto C = readln.chomp.split.to!(int[]); auto D = readln.chomp.split.to!(int[]); auto E = readln.chomp.split.to!(int[]); auto F = readln.chomp.split.to!(int[]); foreach(s; solve(K, A, B, C, D, E, F)){ writeln(s.to!(string[]).join(" ")); } }