#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

#define all(a) a.begin() , a.end()
#define optimus_prime  cin.tie(0); cout.tie(0)
#define endl "\n"
#define vll vector<long long>
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define pb(a) push_back(a)
#define sz size()
#define ll long long
#define F first
#define S second

using namespace std;

const ll N = 101;
const ll inf = 1e9 + 9;
const ll mod = 1e9 + 7;


ll a[N][N];
ll countA = 0;

void solve()
{
    int n, m;
    cin >> n >> m;

    vector<int> dp(m);
    for (int i = 0; i < m; i++) {
        cin >> dp[i];
    }

    set<int> r;

    for (int i = 0; i < n; i++) {
        int current_cost = dp[i];
        set<int> st;
        for (int i : r) {
            st.insert(__gcd(i, current_cost));
        }
        st.insert(current_cost);

        r = st;
    }

    cout << r.size() << endl;
    for (int dp : r) {
        cout << dp << " ";
    }
    cout << endl;


}

signed main()
{
    optimus_prime;

    int t;
    t = 1;
    //cin >> t;

    while(t--)
         solve();





    return 0;
}
