#include <bits/stdc++.h>
#pragma comment(linker, "/stack:16777216")
using namespace std;
int a[10];
int main(int argc, char** argv) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < 10; i++) {
    a[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (n != 1 && s == 0 && c == 0) {
      cout << -1;
      return 0;
    }
    if (a[s] != -1 && a[s] != c) {
      cout << -1;
      return 0;
    }
    a[s] = c;
  }
  if (a[0] == -1) a[0] = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] == -1) {
      a[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i];
  }
  return 0;
}
