結果
| 問題 | 
                            No.5004 Room Assignment
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-12-01 01:44:28 | 
| 言語 | C++17(gcc12)  (gcc 12.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 147 ms / 5,000 ms | 
| コード長 | 2,912 bytes | 
| コンパイル時間 | 1,353 ms | 
| 実行使用メモリ | 22,356 KB | 
| スコア | 137,168,931 | 
| 平均クエリ数 | 7642.54 | 
| 最終ジャッジ日時 | 2021-12-01 01:44:50 | 
| 合計ジャッジ時間 | 21,348 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge14 / judge15 | 
| 純コード判定しない問題か言語 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 100 | 
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#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<int, int>;
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 <class T>
string to_string(T s);
template <class S, class T>
string to_string(pair<S, T> 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 <class T>
string to_string(T v) {
  if (v.empty()) return "{}";
  string ret = "{";
  for (auto x : v) ret += to_string(x) + ",";
  ret.back() = '}';
  return ret;
}
template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + ":" + to_string(p.second) + "}";
}
void debug() { cerr << endl; }
template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
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<vector<Pii>> ls(30);
  REP(t, T) {
    int N;
    cin >> N;
    vector<Pii> S(N);
    vector<Pii> 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;
}