#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s, c;
  cin >> n >> m;
  bool flag = true;
  vector<int> a(9, -1);
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (s == 1 && c == 0 && n != 1) {
      flag = false;
      break;
    } else if (a.at(s - 1) != -1 && a.at(s - 1) != c) {
      flag = false;
      break;
    } else
      a.at(s - 1) = c;
  }
  if (flag) {
    for (int i = 0; i < n; i++) {
      if (a.at(i) != -1)
        cout << a.at(i);
      else if (i == 0)
        cout << "1";
      else
        cout << "0";
    }
  } else
    cout << -1;
}
