#include <bits/stdc++.h>
using namespace std;
int n, m, s;
char c;
int main() {
  cin >> n >> m;
  string d = "";
  bool fl = true;
  for (int i = 0; i < n; i++) d += 'x';
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (s == 1 and c == '0')
      fl = false;
    else if (d[s - 1] == 'x')
      d[s - 1] = c;
    else if (d[s - 1] != 'x' and d[s - 1] != c)
      fl = false;
  }
  for (int i = 0; i < n; i++) {
    if (d[i] == 'x' and n == 1)
      d[i] = '0';
    else if (d[i] == 'x' and i > 0)
      d[i] = '0';
    else if (d[i] == 'x' and i == 0)
      d[i] = '1';
  }
  if (fl)
    cout << d << '\n';
  else
    cout << -1 << '\n';
}
