#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int n, m;
  cin >> n >> m;
  long long int ans = -1;
  string str(n, '-');
  for (long long int i = 0; i < m; i++) {
    long long int s, c;
    cin >> s >> c;
    if (str[s - 1] == '-') {
      if (s == 1 && c == 0) {
        cout << -1 << endl;
        exit(0);
      }
      str[s - 1] = c + '0';
    } else {
      if (str[s - 1] != c + '0') {
        cout << -1 << endl;
        exit(0);
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (str[i] == '-') {
      if (i == 0) {
        str[i] = '1';
      } else {
        str[i] = '0';
      }
    }
  }
  cout << str << endl;
}
