#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma GCC optimize("Ofast") #define REP(i, N) for (int i = 0; i < (int)N; i++) #define FOR(i, a, b) for (int i = a; i < (int)b; i++) #define ALL(x) (x).begin(), (x).end() using namespace std; using Pii = pair; constexpr int inf = 1 << 30; struct Timer { static constexpr double ONE_CLOCK = 0.000000333; unsigned long long get_cycle() { unsigned int low, high; __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); return ((unsigned long long int)low) | ((unsigned long long int)high << 32); } unsigned long long start_time, last_time; Timer() { start_time = last_time = get_cycle(); } int get_time() { return get_cycle() * ONE_CLOCK - start_time * ONE_CLOCK; } int split_time() { return get_cycle() * ONE_CLOCK - last_time * ONE_CLOCK; } void split() { last_time = get_cycle(); } } timer; class RandInt { public: int x = 8753, y = 239017, z = 1000000123; int next(int d) { int t = x ^ (x << 11); x = y; y = z; z ^= (z >> 19) ^ t ^ (t >> 8); return z % d; } } ri; template string to_string(T s); template string to_string(pair p); string to_string(char c) { return string(1, c); } string to_string(string s) { return s; } string to_string(const char s[]) { return string(s); } template string to_string(T v) { if (v.empty()) return "{}"; string ret = "{"; for (auto x : v) ret += to_string(x) + ","; ret.back() = '}'; return ret; } template string to_string(pair p) { return "{" + to_string(p.first) + ":" + to_string(p.second) + "}"; } void debug() { cerr << endl; } template void debug(Head head, Tail... tail) { cerr << to_string(head) << " "; debug(tail...); } template bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } constexpr int T = 3600, R = 4; int id = 1; int main(int argc, char **argv) { int _; cin >> _ >> _; vector> ls(30); REP(t, T) { int N; cin >> N; vector S(N); vector ans; REP(i, N) { cin >> S[i].first; S[i].second = id++; int g = (max(0, S[i].first - 1)) / 5; if (ls[g].size() != 0) { ans.emplace_back(ls[g].back().second, S[i].second); } ls[g].push_back(S[i]); if (ls[g].size() == 4) { ls[g].clear(); } } cout << ans.size() << endl; for (auto p : ans) cout << p.first << " " << p.second << endl; } return 0; }