#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;
void solve() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n, -1);
  bool f = 1;
  for (int i = 0; i < q; ++i) {
    int x, val;
    cin >> x >> val;
    x--;
    if (a[x] == -1 or a[x] == val)
      a[x] = val;
    else
      f = 0;
  }
  if (f == 0) {
    cout << -1;
  }
  if (a[0] == 0 && n != 1) {
    cout << -1;
    return;
  }
  if (a[0] == -1 && n != 1) {
    a[0] = 1;
  } else if (a[0] == -1 && n == 1) {
    a[0] = 0;
  } else {
    for (int i = 0; i < n; ++i) {
      if (a[i] == -1) a[i] = 0;
      cout << a[i];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) solve();
  return 0;
}
