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