#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T>
void drop(const T &x) {
  cout << x << endl;
  exit(0);
}
signed main() {
  int n, m;
  cin >> n >> m;
  string ans(n, '#');
  for (int i = 0; i < m; i++) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if (ans[s] == '#') ans[s] = c;
    if (ans[s] != c) drop(-1);
  }
  if (n > 1 && ans[0] == '0') drop(-1);
  for (int i = 0; i < n; i++) {
    if (ans[i] != '#') continue;
    ans[i] = '0' + (i == 0);
  }
  cout << ans << endl;
  return 0;
}
