#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
const int mod = 2019;
int main() {
  int n, m;
  cin >> n >> m;
  string ans;
  if (n == 1)
    ans = "0";
  else if (n == 2)
    ans = "10";
  else
    ans = "100";
  int count1 = true;
  string count2 = "000";
  for (int i = int(0); i < int(m); i += 1) {
    int a;
    char b;
    cin >> a >> b;
    a--;
    if (count2[a] = '0') {
      ans[a] = b;
      count2[a] = '1';
    } else if (ans[a] != b) {
      count1 = false;
      break;
    }
  }
  if (count1)
    cout << ans << endl;
  else
    cout << -1 << endl;
}
