#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
template <typename T>
void chmin(T &a, const T &b) {
  a = min(a, b);
}
template <typename T>
void chmax(T &a, const T &b) {
  a = max(a, b);
}
struct FastIO {
  FastIO() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} fastiofastio;
const ll INF = 1LL << 60;
void dfs(ll pos, ll num) {}
int main(void) {
  ll n, m;
  cin >> n >> m;
  bool flag = true;
  vector<ll> digit(n, -1);
  for (ll i = (ll)0; i < (ll)m; ++i) {
    ll s, c;
    cin >> s >> c;
    s--;
    if (digit[s] != -1 && c != digit[s]) {
      flag = false;
    }
    digit[s] = c;
  }
  if (digit[0] == 0) flag = false;
  if (!flag) {
    cout << -1 << endl;
    return 0;
  }
  if (digit[0] == -1) digit[0] = 1;
  for (ll i = (ll)1; i < (ll)n; ++i)
    if (digit[i] == -1) digit[i] = 0;
  for (ll i = (ll)0; i < (ll)n; ++i) cout << digit[i];
  cout << endl;
  return 0;
}
