#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string A(n, '0');
  vector<bool> B(n);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if ((B[s] and A[s] - '0' != c) or s == 0 and c == 0) {
      puts("-1");
      return 0;
    }
    A[s] = c + '0';
    B[s] = true;
  }
  cout << A << endl;
}
