#include <bits/stdc++.h>
using namespace std;
int a, b, c[1005], d[1005], mp[1005];
int main() {
  memset(mp, -1, sizeof(mp));
  cin >> a >> b;
  for (int i = 1; i <= b; i++) {
    cin >> c[i] >> d[i];
    if (mp[c[i]] != -1 && mp[c[i]] != d[i] || c[i] == 1 && d[i] == 0) {
      cout << "-1";
      return 0;
    }
    mp[c[i]] = d[i];
  }
  mp[1] == -1 ? cout << "1" : cout << mp[1];
  for (int i = 2; i <= a; i++) mp[i] == -1 ? cout << "0" : cout << mp[i];
  puts("");
}
