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