#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void chMin(T* a, T* b) {
  if (*a > *b) *a = *b;
}
template <typename T>
inline void chMax(T* a, T* b) {
  if (*a < *b) *a = *b;
}
template <typename T>
inline int divUp(T a, T b) {
  return ((a + b - 1) / b);
}
const double PI = acos(-1);
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<char> c(m);
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  char ans[n];
  for (int i = 0; i < n; i++) ans[i] = '0';
  for (int i = 0; i < m; i++) {
    ans[s[i] - 1] = c[i];
  }
  if (ans[0] == '0' && n > 1) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) cout << ans[i];
  cout << endl;
  return 0;
}
