#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string ans(n, '#');
  map<int, int> x;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if (x[a] == 0 || x[a] == b) {
      ans[a - 1] = b + '0';
      x[a] = b;
    } else {
      ans = "-1";
      break;
    }
  }
  if ((ans[0] == '0' && ans.size() != 1) || ans == "-1")
    cout << -1;
  else {
    for (int i = 0; i < n; ++i)
      if (ans[i] == '#') {
        if (i == 0)
          ans[i] = '1';
        else
          ans[i] = '0';
      }
    cout << ans;
  }
}
