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