#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 100000;
int main() {
  long long N, M, ts, tc;
  int ans = 0;
  vector<long long> s;
  vector<long long> c;
  long long num[10];
  long long count[10];
  for (int i = 0; i < (3); i++) {
    num[i] = 0;
    count[i] = 0;
  }
  bool flg = true;
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    cin >> ts >> tc;
    s.push_back(ts);
    c.push_back(tc);
    if (num[ts] != tc && count[ts] > 0) {
      flg = false;
    }
    count[ts]++;
    num[ts] = tc;
    cout << ts << ":" << num[ts] << endl;
  }
  for (int i = 0; i < (M); i++) {
    if (s[i] == 1 && c[i] == 0) flg = false;
  }
  if (!flg) {
    cout << -1;
  } else {
    for (int i = 1; i <= N; i++) {
      ans += num[i] * pow(10, N - i);
    }
    cout << ans;
  }
  return 0;
}
