#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  int s[m], c[m];
  for (int i = 0; i < n; i++) {
    v[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  bool ok = true;
  for (int i = 0; i < m; i++) {
    if (v[s[i]] == -1 || v[s[i]] == c[i]) {
      v[s[i]] = c[i];
    } else {
      ok = false;
    }
  }
  if (ok && (v[0] != 0)) {
    for (int i = 0; i < n; i++) {
      if (v[i] == -1) {
        if (i == 0)
          cout << 1;
        else
          cout << 0;
      } else {
        cout << v[i];
      }
    }
  } else {
    cout << -1;
  }
}
