#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
const ll MOD = 1e9 + 7, N = 1e5 + 10;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, m;
  cin >> n >> m;
  if (n == 1 and m == 0) {
    cout << "0";
    return 0;
  }
  string ans = "000";
  for (ll i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    if (ans[a] != '0') {
      if (ans[a] != b + '0') {
        cout << "-1\n";
        return 0;
      }
    } else {
      ans[a] = b + '0';
    }
    if (!a and !b) {
      cout << "-1\n";
      return 0;
    }
  }
  if (ans[0] == '0') ans[0] = '1';
  cout << ans;
  return 0;
}
