#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, c[10];
  bool check, done[10];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (!done[a]) {
      c[a] = b;
      done[a] = true;
    } else if (c[a] != b)
      check = true;
    if (a == 1 && b == 0 && n != 1) check = true;
  }
  if (check) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (done[i])
      cout << c[i];
    else if (i == 1)
      cout << 1;
    else
      cout << 0;
  }
  cout << endl;
  return 0;
}
