#include <bits/stdc++.h>
using namespace std;
int a[111];
int s[111], c[111];
int main() {
  memset(a, (0xff), sizeof a);
  int n, m;
  cin >> n >> m;
  bool f = 0;
  for (int i = 0; i < (m); ++i) {
    cin >> s[i] >> c[i];
    if (a[s[i]] != -1 && a[s[i]] != c[i])
      f = 1;
    else
      a[s[i]] = c[i];
  }
  if (f)
    cout << "-1" << endl;
  else if (n > 1 && a[1] == 0)
    cout << "-1" << endl;
  else {
    for (int i = 1; i <= (n); ++i) {
      if (a[i] == -1) {
        if (i == 1)
          a[i] = 1;
        else
          a[i] = 0;
      }
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}
