#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<char> ans(n);
  for (ll i = 0; i < n; ++i) ans[i] = '?';
  for (ll i = 0; i < m; ++i) {
    ll s;
    char c;
    cin >> s >> c;
    s--;
    if (ans[s] == '?')
      ans[s] = c;
    else if (ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans[0] == '0' && n != 1) {
    cout << -1 << endl;
    return 0;
  }
  if (ans[0] == '?') ans[0] = '1';
  for (ll i = 0; i < n; ++i)
    if (ans[i] == '?') ans[i] = '0';
  for (ll i = 0; i < n; ++i) cout << ans[i];
}
