#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  string ans = "1";
  for (int(i) = 0; (i) < (N - 1); (i)++) ans += "0";
  vector<pair<int, char>> sc(M);
  int s;
  char c;
  for (int(i) = 0; (i) < (M); (i)++) {
    cin >> s >> c;
    sc[i] = make_pair(s, c);
  }
  vector<bool> check(N);
  for (int(i) = 0; (i) < (M); (i)++) {
    sc[i].first = s;
    sc[i].second = c;
    if ((check[s - 1] && ans[s - 1] != c) || s > N || (s == 1 && c == '0')) {
      cout << -1 << endl;
      return 0;
    }
    ans[s - 1] = c;
    check[s - 1] = 1;
  }
  cout << ans << endl;
  return 0;
}
