#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001000;
const int mINF = -1001001000;
const long long LINF = 10100100100100100;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  vector<int> s(m), c(m);
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  bool ans = true;
  for (int i = 0; i < m; i++) {
    if (a[s[i]] == -1)
      a[s[i]] = c[i];
    else {
      if (a[s[i]] != c[i]) ans = false;
    }
  }
  if (a[0] == 0) ans = false;
  if (!ans) {
    cout << -1 << endl;
    return 0;
  }
  if (a[0] == -1) a[0] = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) a[i] = 0;
  }
  for (int i = 0; i < n; i++) cout << a[i];
  return 0;
}
