#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  memset(a, 0, sizeof(a));
  bool can = true;
  vector<int> vis(n, 0);
  int p = m;
  while (p--) {
    int x, y;
    cin >> x >> y;
    x--;
    if (vis[x] && y != a[x]) {
      can = false;
      break;
    }
    vis[x] = 1;
    a[x] = y;
  }
  if (m == 0) {
    cout << pow(10, n - 1);
    return 0;
  }
  string l = "";
  if (!vis[0]) {
    a[0] = 1;
  }
  for (int i = 0; i < n; i++) {
    l += (a[i] + '0');
  }
  if (l.length() < n || l.length() > n || can == false ||
      (l[0] == '0' && n != 1)) {
    cout << -1;
    return 0;
  }
  cout << l;
}
