#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<char> ans(n, '0');
  for (int i = 0; i < m; i++) {
    int s;
    char c;
    cin >> s >> c;
    ans[s - 1] = c;
  }
  if (ans[0] == '0' && n != 1) {
    cout << -1;
    return;
  }
  for (auto x : ans) {
    cout << x;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
