#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
  fill((T*)array, (T*)(array + N), val);
}
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
  bool operator()(const std::pair<T1, T2>& left,
                  const std::pair<T1, T2>& right) {
    Pred p;
    return p(left.second, right.second);
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  string s = string(N, '0');
  vector<char> m(N, '-1');
  s[0] = '1';
  for (int i = (0); i < (int)(M); i++) {
    int a;
    char b;
    cin >> a >> b;
    if (m[a - 1] != '-1' && m[a - 1] != b) {
      cout << -1 << endl;
      return 0;
    }
    s[a - 1] = b;
    m[a - 1] = b;
  }
  if (s[0] == '0' && s.size() != 1) {
    cout << -1 << endl;
    return 0;
  }
  cout << s << endl;
  return 0;
}
