#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> num(n + 1);
  for (int i = 0; i < n + 1; i++) num[i] = -1;
  bool ok = true;
  for (int i = 1; i <= m; i++) {
    int c, s;
    cin >> s >> c;
    if (num[s] == -1)
      num[s] = c;
    else {
      if (num[s] != c) ok = false;
    }
  }
  if (num[1] == 0) ok = false;
  if (!ok)
    cout << -1 << endl;
  else {
    for (int i = 1; i <= n; i++) {
      if (num[i] == -1) num[i] = 1;
      cout << num[i];
    }
    cout << endl;
  }
  return 0;
}
