#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
const long long INFLL = 1000000000000000007LL;
void solve() {
  int N, M;
  cin >> N >> M;
  string ans = "";
  vector<bool> mask(N, false);
  for (int i = 0; i < N; i++) {
    ans += 'x';
  }
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if (ans[s - 1] == 'x' || ans[s - 1] == c + '0') {
      ans[s - 1] = c + '0';
      mask[s - 1] = true;
    } else {
      cout << -1 << endl;
      return;
    }
  }
  for (int i = 0; i < N; i++) {
    if (ans[i] == 'x') {
      ans[i] = '0';
    }
  }
  if (ans[0] == '0' && !mask[0]) {
    ans[0] = '1';
  }
  if (ans.size() > 1 && ans[0] == '0') {
    cout << -1 << endl;
    return;
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
