#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  string ans(N, '0');
  map<int, int> m;
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    if (m.count(x) != 0 && m[x] != y) {
      cout << -1 << endl;
      return 0;
    }
    m[x] = y;
  }
  for (auto iter = m.begin(); iter != m.end(); iter++) {
    if (iter->first - 1 == 0 && iter->second == 0 && N != 1) {
      cout << -1 << endl;
      return 0;
    }
    ans[iter->first - 1] = iter->second + '0';
  }
  if (ans[0] == '0') ans[0] = '1';
  cout << ans << endl;
}
