#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647;
const double PI = acos(-1);
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
void debug(T v) {
  for (int i = 0; i < v.size(); ++i) cout << v[i] << " ";
  cout << endl;
}
const long long dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < m; ++i) cin >> s[i] >> c[i];
  string res;
  if (n == 1)
    res = "0";
  else if (n == 2)
    res = "10";
  else
    res = "100";
  for (int i = 0; i < m; ++i) {
    for (int j = i + 1; j < m; j++) {
      if (s[i] == s[j] && c[i] != c[j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    if (s[i] == 1 && c[i] == 0 && n != 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < m; ++i) {
    res[s[i] - 1] = '0' + c[i];
    cout << res << endl;
  }
  cout << res << endl;
}
