#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  int num[3] = {-1, -1, -1};
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (num[s] == -1) {
      num[s] = c;
    } else {
      if (num[s] != c) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (num[i] == -1) {
        cout << 1;
      } else if (num[i] == 0) {
        cout << "-1" << endl;
        return 0;
      } else {
        cout << num[i];
      }
    } else {
      if (num[i] == -1) {
        cout << 0;
      } else {
        cout << num[i];
      }
    }
  }
  cout << endl;
  return 0;
}
