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