#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;
#define ll long long

void XorDelilaca(const vector<ll>& del, vector<ll>& br,  ll n, int k, int j, int indeks, ll tr){
    ll x;
    x= br[indeks]^tr;
    if(indeks>n) return;
    if(n%x!=0) return;
    if(j){
        br[indeks*tr]=br[indeks]^tr;
        for(int i=0;i<k;i++){
            XorDelilaca(del, br, n, k, j-1, indeks*tr, del[i]);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    int k;
    cin>>n>>k;
    vector<ll> del;
    ll x;
    vector<ll> res;
    for(int i=0;i<k;i++){
        cin>>x;
        del.push_back(x);
        res.push_back(x);
    }
    vector<ll> br(k,0);
    br[1]=1;
    sort(res.begin(),res.end());
    XorDelilaca(res, br, n, k, k, 1, 1);
    for(int i=0;i<k;i++){
        cout<<res[del[i]]<<" ";
    }
}