#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7LL;
const int INF = 2e9;
int N, M;
vector<pair<int, char> > a;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M;
  int s;
  char c;
  for (int i = 0; i < M; ++i) {
    cin >> s >> c;
    s--;
    a.push_back(pair<int, char>(s, c));
  }
  string ans = "";
  for (int i = 0; i < N; ++i) ans += '-';
  for (int i = 0; i < M; ++i) {
    int d = a[i].first;
    char v = a[i].second;
    if (ans[d] != '-' && ans[d] != v) {
      cout << -1 << "\n";
      return 0;
    }
    if (d == 0 && v == '0') {
      if (N != 1) {
        cout << -1 << "\n";
        return 0;
      }
    }
    ans[d] = v;
  }
  for (int i = 0; i < N; ++i) {
    if (ans[i] == '-') {
      ans[i] = i == 0 ? '1' : '0';
    }
  }
  cout << ans << "\n";
  return 0;
}
