#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
inline ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
inline ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> sc(m);
  for (int i = (0); i < m; ++i) {
    int s, c;
    cin >> s >> c;
    sc[i].first = s;
    sc[i].second = c;
  }
  vector<int> ans(n, -1);
  for (int i = (0); i < m; ++i) {
    if (sc[i].first == 1 && sc[i].second == 0) {
      cout << "-1";
      return 0;
    }
    for (int j = (0); j < m; ++j) {
      if (i != j && sc[i].first == sc[j].first &&
          sc[i].second != sc[j].second) {
        cout << "-1";
        return 0;
      }
    }
  }
  for (int i = (0); i < m; ++i) {
    for (int j = (0); j < m; ++j) {
      if (i + 1 == sc[j].first) {
        ans[i] = sc[j].second;
      }
    }
  }
  for (int i = (0); i < n; ++i) {
    if (ans[i] == -1) {
      if (i == 0) {
        ans[i] = 1;
      } else {
        ans[i] = 0;
      }
    }
  }
  for (int i = (0); i < n; ++i) {
    cout << ans[i];
  }
  return 0;
}
