#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
#define GETIN2MACRO(_1, _2, NAME, ...) NAME
#define GETIN3MACRO(_1, _2, _3, NAME, ...) NAME
#define GETIN4MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define GETIN5MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
#define GETIN6MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define GETIN7MACRO(_1, _2, _3, _4, _5, _6, _7, NAME, ...) NAME
#define INPUT1(n) \
  ll n;           \
  cin >> n
#define INPUT2(a, b) \
  ll a, b;           \
  cin >> a >> b
#define INPUT3(n, a, b) \
  ll n, a, b;           \
  cin >> n >> a >> b
#define INPUT4(n, m, a, b) \
  ll n, m, a, b;           \
  cin >> n >> m >> a >> b
#define INPUT(...)                                         \
  GETIN4MACRO(__VA_ARGS__, INPUT4, INPUT3, INPUT2, INPUT1) \
  (__VA_ARGS__)
#define INPUTARR(n, a) \
  ll a[n];             \
  REP(i, n) { cin >> a[i]; }
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
template <class T>
void DEBUGARR(const T* const t, const ll size) {}
template <class T>
void DEBUGARRL(const T* const t, const ll size) {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
template <class T>
void DEBUGARR(const T* const t, const ll size) {
  DEBUG("ARRAY size:", size);
  PRINTa(t, size);
}
template <class T>
void DEBUGARRL(const T* const t, const ll size) {
  DEBUG("ARRAY size:", size);
  PRINTal(t, size);
}
#endif
#ifdef ANS
#else
#endif
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}

// search max depth
ll dfs(vector<vector<ll>>& tree, ll parent, ll now, ll depth) {
  ll d = depth;
  for (auto i : tree[now]) {
    if (i == parent) continue;
    d = max(d, dfs(tree, now, i, depth + 1));
  }
  return d;
}

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  //solve
  INPUT(n,m);
  ll s[m];
  char c[m];
  REP(i,m){
    cin>>s[i]>>c[i];
  }REP(i,m){
    s[i]--;
  }
  char ans[n+1];
  memset(ans,0,(n+1)*sizeof(char));
  REP(i,m){
    if(ans[s[i]]==0||ans[s[i]]==c[i]){
      ans[s[i]]=c[i];
    }else{
      PRINT(-1);return;
    }
  }
  REP(i,n){
    if(ans[i]==0)ans[i]=i==0&&n!=1?'1':'0';
  }
  ans[0]=='0'&&n!=1?PRINT(-1):PRINT(ans);

  return;
}

Measured memory_bytes: 256