#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  bool flag = false;
  for (int i = 0; i < m; i++) {
    s[i] = "NULL";
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    string str;
    str = to_string(y);
    if (s[x - 1] == "NULL") {
      s[x - 1] = str;
    } else {
      if (s[x - 1] != str) flag = true;
    }
  }
  for (int i = 0; i < m; i++) {
    if (i == 0) {
      if (s[i] == "NULL") s[i] = "1";
    } else {
      if (s[i] == "NULL") {
        s[i] = "0";
      }
    }
  }
  if (flag || s[0] == "0") {
    cout << "-1" << endl;
  } else {
    string str;
    for (int i = 0; i < n; i++) {
      str += s[i];
    }
    cout << str << endl;
  }
}
