#include <bits/stdc++.h>
using namespace std;
const long long int INF = LONG_LONG_MAX >> 1;
const long long int NINF = LONG_LONG_MIN;
const long long int mmod = 100000000000ll;
long long int used[3][3];
long long int len(long long int n) {
  long long int cnt = 1;
  while (n / 10) {
    n /= 10;
    cnt++;
  }
  return cnt;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n, m;
  cin >> n >> m;
  vector<pair<long long int, long long int> > list;
  for (long long int i = 0; i < m; i++) {
    long long int s, c;
    cin >> s >> c;
    list.push_back({s, c});
  }
  set<pair<long long int, long long int> > s;
  for (long long int i = 0; i < m; i++) {
    s.insert({list[i].first, list[i].second});
  }
  vector<pair<long long int, long long int> > new_list;
  for (pair<long long int, long long int> p : s) {
    new_list.push_back(p);
  }
  bool ok = true;
  for (long long int i = 1; i < m; i++) {
    if (new_list[i].first == new_list[i - 1].first) {
      ok = false;
    }
  }
  if (n == 1 && (long long int)new_list.size() == 1) {
    if (new_list[0].first == 1 && new_list[0].second == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (n == 1 && m == 0) {
    cout << 1 << endl;
    return 0;
  }
  if (ok) {
    string ans(n, 'a');
    for (pair<long long int, long long int> p : s) {
      ans[p.first - 1] = p.second + '0';
    }
    bool prefix = true;
    bool correct = true;
    for (long long int i = 0; i < n; i++) {
      if (prefix && ans[i] == '0') correct = false;
      if (ans[i] == 'a') {
        if (prefix) {
          ans[i] = '1';
          prefix = false;
        } else
          ans[i] = '0';
      } else {
        prefix = false;
      }
    }
    if (correct) {
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  } else {
    cout << -1 << endl;
  }
}
