#include <bits/stdc++.h>
using namespace std;
void show_p(pair<int, int> p) {
  cout << '(' << p.first << ' ' << p.second << ')' << endl;
}
bool check_redundant(vector<pair<int, int>>& v) {
  if (v.size() <= 1) return false;
  for (int i = 0; i < v.size() - 1; i++) {
    if (v[i].first == v[i + 1].first) return true;
  }
  return false;
}
void fail() {
  cout << -1 << endl;
  exit(0);
}
int digit(int n) {
  if (n == 0) return 1;
  int cnt = 0;
  while (n) {
    cnt++;
    n /= 10;
  }
  return cnt;
}
int build_number(vector<pair<int, int>>& v, int N) {
  vector<int> dig(N, -1);
  for (auto e : v) {
    dig[e.first] = e.second;
  }
  for (int i = 0; i < N; i++) {
    if (dig[i] == -1) {
      if (i == 0)
        dig[i] = 1;
      else
        dig[i] = 0;
    }
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    res *= 10;
    res += dig[i];
  }
  return res;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> v;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    v.push_back(make_pair(s, c));
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  if (check_redundant(v)) fail();
  int res = build_number(v, N);
  if (digit(res) == N)
    cout << res << endl;
  else
    cout << -1 << endl;
  return 0;
}
