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