#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int g = gcd(b, a % b, x, y);
  int t1 = y;
  int t2 = x - (a / b) * y;
  x = t1;
  y = t2;
  return g;
}
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  int flag = 0;
  for (int i = 0; i < n; ++i) a[i] = -1;
  while (m--) {
    int x, y;
    cin >> x >> y;
    x--;
    if (a[x] == -1)
      a[x] = y;
    else if (a[x] != y) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    cout << "-1";
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == -1) {
      if (flag)
        cout << "0";
      else {
        cout << "1";
        flag = 1;
      }
      continue;
    }
    cout << a[i];
    flag = 1;
  }
  return 0;
}
