#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  bool flag = true;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if ((a[s - 1] == -1) || (a[s - 1] == c))
      a[s - 1] = c;
    else {
      a[0] = -1;
      flag = false;
      break;
    }
  }
  if (flag && a[0] == -1) a[0] = 1;
  if ((a[0] == -1) || (a[0] == 0))
    cout << "-1" << endl;
  else {
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) a[i] = 0;
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}
