#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2 != 0) {
      ans = (ans * a) % 1000000007;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    int n, m;
    cin >> n >> m;
    string s;
    for (int i = 0; i < n; i++) s += 'a';
    while (m--) {
      int p, q;
      cin >> p >> q;
      if (s[p - 1] == 'a') {
        s[p - 1] = q + '0';
      } else {
        int z = s[p - 1] - '0';
        if (z != q) {
          cout << -1;
          return 0;
        }
      }
    }
    if (s[0] == '0' && s.size() != 1) {
      cout << -1;
      return 0;
    }
    for (int i = 0; i < n; i++) {
      if (s[i] == 'a') {
        if (i == 0 || s.size() == 1) {
          s[i] = '1';
        } else
          s[i] = '0';
      }
    }
    cout << s;
  }
  return 0;
}
