The input consists of a single test case and is given in the following format:
mnta11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮am1am2⋯amnb11b12⋯b1nb21b22⋯b2n⋮⋮⋱⋮bm1bm2⋯bmni1j1k1i2j2k2⋮⋮⋮itjtkt
Bounds on the values are: 1 ≤ m, n ≤ 20; 1 ≤ t ≤ 1000; 0 ≤ aij, bij ≤ 10; 1 ≤ it ≤ m; 1 ≤ jt ≤ n; 1 ≤ kt ≤ 109.