#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const long long MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> num(n, -1);
  bool ans = true;
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    if (n != 1 && s == 1 && c == 0) {
      ans = false;
      break;
    }
    if (num[s - 1] == -1 || num[s - 1] == c)
      num[s - 1] = c;
    else {
      ans = false;
      break;
    }
  }
  if (!ans)
    cout << "-1" << endl;
  else {
    for (int i = 0; i < (int)(n); i++) {
      if (num[i] == -1) {
        if (i == 0)
          cout << "1";
        else
          cout << "0";
      } else
        cout << num[i];
    }
    cout << endl;
  }
}
