intmain() { int n, m, l, r, count; scanf(" %d %d", &n, &m); while (n--) { count = l = r = 0; for (int i = 0; i < m; i++) readUInt(&lhs[i]); for (int i = 0; i < m; i++) readUInt(&rhs[i]); for (;;) { if (lhs[l] < rhs[r]) { if (++l == m) break; } elseif (rhs[r] < lhs[l]) { if (++r == m) break; } else { count++; if (++l == m) break; if (++r == m) break; } } printf("%d\n", count); } return0; }