#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  string ans = "1";
  for (int i = 0; i < N - 1; i++) ans += "0";
  int s;
  char c;
  map<int, char> mp;
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    s--;
    if (s == 0 && c == '0') {
      ans = "-1";
      break;
    } else if (mp[s] == 0 || mp[s] == c) {
      ans[s] = c;
      mp[s] = c;
    } else {
      ans = "-1";
      break;
    }
  }
  cout << ans << endl;
}
