#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  bool ok = 1;
  int n, m, index;
  char x;
  cin >> n >> m;
  string num = "";
  for (long long i = 0; i < n; i++) num.push_back('-');
  num[0] = '1';
  for (long long i = 0; i < m; i++) {
    cin >> index >> x;
    if (index != 1 && num[index - 1] != '-')
      ok = 0;
    else {
      num[index - 1] = x;
    }
  }
  for (long long i = 0; i < n; i++)
    if (num[i] == '-') num[i] = '0';
  if (n == 1 && num == "0") {
    cout << 0 << "\n";
    return 0;
  }
  if (!ok || num[0] == '0')
    cout << -1 << "\n";
  else
    cout << num << "\n";
  return 0;
}
