#include <bits/stdc++.h>
using namespace std;

using lnt = long long;
template <class T> using SET = unordered_set<T>;
template <class T, class S> using MAP = unordered_map<T, S>;

#define LOOP(n) for (lnt _ = 0; _ < (n); _++)
#define ILOOP(n) for (lnt _ = (n)-1; _ >= 0; _--)
#define REP(i, n) for (lnt i = 0; i < (n); i++)
#define IREP(i, n) for (lnt i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (lnt i = (a); i < (b); i++)
#define IFOR(i, a, b) for (lnt i = (b)-1; i >= (a); i--)
#define ALL(a) a.begin(), a.end()

#define MAXELM max_element
#define MINELM min_element
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define PB push_back

#define MAIN int main

lnt inline POW(const lnt x, const lnt y) {
  lnt init = 1;
  for (lnt i = 0; i < y; i++) {
    init *= x;
  }
  return init;
}

lnt inline BIT(const lnt i) { return POW(2, i); }

lnt inline MASK(const lnt value, const lnt position, const lnt base = 10) {
  if (base >= 2)
    return (value / POW(base, position)) % base;
  else {
    cout << "WARNING! the 'base' argument is evaluated by the integer less "
            "than 2."
         << endl;
    return 0;
  }
}

lnt inline BMASK(const lnt value, const lnt position) {
  return MASK(value, position, 2);
}

lnt inline DIGIT(const lnt value, const lnt position, const lnt base = 10) {
  if (base >= 2) {
    if (value == 0) {
      if (position == 0)
        return 0;
      else
        return base;
    } else {
      if (value < POW(base, position))
        return base;
      else
        return MASK(value, position, base);
    }
  } else {
    cout << "WARNING! the 'base' argument is evaluated by the integer less "
            "than 2."
         << endl;
    return 0;
  }
}

lnt inline BDIGIT(const lnt value, const lnt position) {
  return DIGIT(value, position, 2);
}

const lnt INF = 2 * POW(10, 18); // cf. LLONG_MAX ≒ 9x10^18

template <class T, class S>
lnt inline CNT(const T &iteraterFirst, const T &iteraterLast, const S &value) {
  return (lnt)count(iteraterFirst, iteraterLast, value);
}

template <class T>
lnt inline DIST(const T &iteraterFirst, const T &iteraterLast) {
  return (lnt)distance(iteraterFirst, iteraterLast);
}

template <class T> lnt inline SIZE(const T &sequence) {
  return (lnt)(sequence.size());
}

template <class T> string inline STR(const T &value) {
  return to_string(value);
}

lnt inline ABS(const lnt &value) { return abs(value); }

lnt inline MAX(const lnt &value1, const lnt &value2) {
  return max(value1, value2);
}

lnt inline MIN(const lnt &value1, const lnt &value2) {
  return min(value1, value2);
}

MAIN() {
  lnt n, m;
  cin >> n >> m;
  vector<pair<pair<lnt, lnt>, lnt>> vcTr;
  REP(city, m) {
    lnt a, b;
    cin >> a >> b;
    vcTr.PB(pair<pair<lnt, lnt>, lnt>(pair<lnt, lnt>(a, b), city));
  }

  sort(ALL(vcTr));
  vector<lnt> p, vcCity;
  REP(i, m) {
    p.PB(vcTr[i].F.F);
    vcCity.PB(vcTr[i].S);
  }

  vector<lnt> vcPrefIndexedByCity(m), vcOrderIndexedByCity(m);
  FOR(pref, 1, n + 1) {
    lnt indexBegin = DIST(p.begin(), LB(ALL(p), pref)),
        indexEnd = DIST(p.begin(), UB(ALL(p), pref));
    FOR(i, indexBegin, indexEnd) {
      lnt order = i - indexBegin + 1;
      vcPrefIndexedByCity[vcCity[i]] = pref;
      vcOrderIndexedByCity[vcCity[i]] = order;
    }
  }

  REP(city, m) {
    IREP(j, 6) { cout << MASK(vcPrefIndexedByCity[city], j); }
    IREP(j, 6) { cout << MASK(vcOrderIndexedByCity[city], j); }
    cout << endl;
  }
}


Measured memory_bytes: 8304