#include <bits/stdc++.h>
using namespace std;
long long strtoint(string str);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, s, c;
  cin >> n >> m;
  vector<int> arr(n, -1);
  vector<bool> ok(n, 1);
  bool tmp = 1;
  map<long long, long long> mp;
  for (auto i = 0; i < m; ++i) {
    cin >> s >> c;
    if (ok[s - 1]) {
      arr[s - 1] = c;
      ok[s - 1] = 0;
      mp[s - 1] = c;
    }
    if (!ok[s - 1] && mp[s - 1] != c) tmp = 0;
  }
  for (auto i = 0; i < n; ++i) {
    if (ok[i]) {
      if (i == 0)
        arr[i] = 1;
      else
        arr[i] = 0;
    }
  }
  if (tmp) {
    for (auto i = 0; i < n; ++i) cout << arr[i];
  } else
    cout << "-1";
  cout << '\n';
  return 0;
}
long long strtoint(string str) {
  long long x = 0;
  stringstream ss;
  ss << str;
  ss >> x;
  return x;
}
