#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ;
  int n, m;
  int d[5];
  bool ok = true;
  memset(d, -1, sizeof(d));
  cin >> n >> m;
  for (int i = 0; i != (int)m; ++i) {
    int s, c;
    cin >> s >> c;
    if ((s == 1 && c == 0) || (d[s] != -1 && d[s] != c)) {
      ok = false;
      break;
    }
    d[s] = c;
  }
  if (ok == false) {
    cout << "-1\n";
    return 0;
  }
  d[1] = max(d[1], 1);
  for (int i = 2; i != (int)n + 1; ++i) {
    d[i] = max(d[i], 0);
  }
  for (int i = 1; i != (int)n + 1; ++i) {
    cout << d[i];
  }
  cout << '\n';
}
