#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long INF = 1e12;
const int MOD = 1e9 + 7;
const unsigned long long BIT_FLAG_0 = (1 << 0);
const unsigned long long BIT_FLAG_1 = (1 << 1);
const unsigned long long BIT_FLAG_2 = (1 << 2);
const unsigned long long BIT_FLAG_3 = (1 << 3);
const unsigned long long BIT_FLAG_4 = (1 << 4);
const unsigned long long BIT_FLAG_5 = (1 << 5);
const unsigned long long BIT_FLAG_6 = (1 << 6);
const unsigned long long BIT_FLAG_7 = (1 << 7);
const long long dx[4] = {1, 0, -1, 0};
const long long dy[4] = {0, 1, 0, -1};
void print() { cout << endl; }
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto &vec : df) {
    print(vec);
  }
}
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, char>> cond;
  for (long long i = 0; i < long long(m); i++) {
    long long s;
    char c;
    cin >> s >> c;
    cond.push_back(make_pair(s, c));
  }
  for (long long i = pow(10, n - 1); i < long long(pow(10, n)); i++) {
    string vals = to_string(i);
    bool can = true;
    for (long long j = 0; j < long long(m); j++) {
      if (vals[cond[j].first - 1] != cond[j].second) {
        can = false;
        break;
      }
    }
    if (can) {
      print(i);
      exit(0);
    }
  }
  print(-1);
}
