#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k = 0, s, c, n, m;
  cin >> n >> m;
  int a[n];
  for (i = 0; i < n; i++) a[i] = 99;
  for (i = 0; i < m; i++) {
    cin >> s >> c;
    if (s == 1 && c == 0) {
      k++;
      break;
    } else if (a[s - 1] != 99 && c != a[s - 1]) {
      k++;
      break;
    } else {
      a[s - 1] = c;
    }
  }
  if (k > 0)
    cout << "-1";
  else {
    for (i = 1; i < n; i++) {
      if (a[i] == 99) a[i] = 0;
    }
    if (a[0] == 99) a[0] = 1;
    for (i = 0; i < n; i++) cout << a[i];
  }
}
