#include <bits/stdc++.h>
using namespace std;
class DebugStream {
} LOG;
template <typename T>
DebugStream &operator<<(DebugStream &s, const T &) {
  return s;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20,
          bs = 29;
char crs[maxN];
int poss[maxN], n, m;
bool testea(int num) {
  string str = to_string(num);
  for (int i = 0; i < m; i++)
    if (str[poss[i]] != crs[i]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> poss[i] >> crs[i], poss[i]--;
  int ans = -1;
  int pot = 1;
  while (n--) pot *= 10;
  for (int i = pot / 10; ans == -1 && i < pot; i++)
    if (testea(i)) ans = i;
  cout << ans << '\n';
}
