#include <iostream>
#include <vector>
#include <string>

//using namespace std;

int main()
{
    uint32_t nn;
    /* nn <= 3 so nn is smaller than 1000 */
    uint32_t mm;
    uint32_t tar;
    uint32_t dig1 = 0;
    uint32_t dig2 = 0;
    uint32_t dig3 = 0;

    std::cin >> nn >> mm;

    std::vector<std::vector<int>> vv(2, std::vector<int>(mm, 0));
    
    for(int i = 0; i < mm; i++){
        for(int j = 0; j < 2; j++){
            std::cin >> vv[j][i];
        }
    }
    
    for(int i = 0; i < mm; i++){
        for(int j = 0; j < 2; j++){
            std::cout << vv[j][i];
        }
        std::cout << std::endl;
    }
    /* N桁目の数字になるかでプローブ領域を変える */

    if(nn == 1){
        std::cout << "1des" << std::endl;
        for(int i = 0; i < 10; i++){
        /* s_i桁目の数字 */
            dig3 = i;
            for(int k = 0; k < mm; k++){
                if(vv[0][k] != 1){
                    break;
                }
                if(dig3 != vv[1][k]){
                    break;
                }
                std::cout << i << std::endl;
                return 0;
            }
        }

    }else if(nn == 2){
        std::cout << "2des" << std::endl;
        for(int i = 10; i < 100; i++){
        /* s_i桁目の数字 */
            dig3 = i % 10;
            dig2 = i / 10;
            for(int k = 0; k < mm; k++){
                if(vv[0][k] == 3){
                    break;
                }else if(vv[0][k] == 1){
                    if(dig2 != vv[1][k]){
                        break;
                    }
                }else if(vv[0][k] == 2){
                    if(dig3 != vv[1][k]){
                        break;
                    }
                }
                std::cout << i << std::endl;
                return 0;
            }
        }

    }else if(nn == 3){
        std::cout << "3des" << std::endl;
        for(int i = 100; i < 1000; i++){
            dig3 = (i % 100) % 10;
            dig2 = (i % 100) /10;
            dig1 = i / 100;
            for(int k = 0; k < mm; k++){
                if(vv[0][k] == 1){
                    if(dig1 != vv[1][k]){
                        std::cout << "noi " << i << std::endl;
                        break;
                    }
                }

                if(vv[0][k] == 2){
                    if(dig2 != vv[1][k]){
                        break;
                    }
                }
                
                if(vv[0][k] == 3){
                    std::cout << i << std::endl;
                    if(dig3 != vv[1][k]){
                        break;
                    }
                }
            }
            
        }
        std::cout << i << std::endl;
            return 0;
    }

    std::cout << "aho" << std::endl;
    return 0;
}