#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> digit;
  int ans[n + 1];
  for (int i = 0; i <= n; i++) {
    ans[i] = -1;
  }
  map<int, int>::iterator itr;
  for (int i = 1; i <= m; i++) {
    int pos, val;
    cin >> pos >> val;
    if ((digit.count(pos) == true && digit[pos] != val)) {
      cout << "-1" << endl;
      return 0;
    }
    digit[pos] = val;
  }
  for (itr = digit.begin(); itr != digit.end(); itr++) {
    ans[itr->first] = itr->second;
  }
  if (n != 1 && ans[1] == 0) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] == -1 && i != 1)
      cout << "0";
    else if (ans[i] > 0)
      cout << ans[i];
    else
      cout << "1";
  }
  cout << endl;
  return 0;
}
