#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const long long MOD = 1e9 + 7;
long long N, M;
int main() {
  cin >> N >> M;
  string ans;
  ans.resize(N);
  for (long long i = 0; i < N; i++) {
    ans[i] = '-';
  }
  for (long long i = 0; i < M; i++) {
    long long s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[s - 1] == '-' || ans[s - 1] == c + '0') {
      ans[s - 1] = c + '0';
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans[0] == '-') {
    ans[0] = '1';
  }
  for (long long i = 1; i < N; i++) {
    if (ans[i] == '-') {
      ans[i] = '0';
    }
  }
  cout << ans << endl;
  return 0;
}
