#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long inf = 1e18;
int a[3];
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) a[i] = -1;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (a[s] == -1) {
      a[s] = c;
    } else {
      if (a[s] != c) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (a[0] == 0 && n == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (a[0] == -1) {
    a[0] = 1;
  } else if (a[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] == -1) a[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    cout << a[i];
  }
  cout << endl;
  return 0;
}
