#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define MINF -(int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535
#define ff first
#define ss second

#ifdef DEBUG
#define DBG if(1)
#else
#define DBG if(0)
#endif

#define dbg(x) cout << "(" << #x << " : " << x << ")" << endl;

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template<class T>
ostream& operator<<(ostream& out, const vector<T> &v){
    out << "[";
    REP(i, v.size()) out << v[i] << ", ";
    out << "]";
    return out;
}
class edge{
    public:
        int src, dest;
        ll w;
        edge(int from, int to, ll weight){
            src = from;
            dest = to;
            w = weight;
        }
    };
class undigraph{
    public:
        int n;
        vector<edge> edges;
        vector<vi> adj;
        undigraph(int n){
            this->n = n;
            adj.resize(n);
        }
        void add_edge(int u, int v, ll w){
            edges.pb(edge(u, v, w));
            int id = edges.size()-1;
            adj[u].pb(id);
            adj[v].pb(id);
        }
    };
vector<bool> bad;
bool check(double x, undigraph &g, vi &ans, bool construct){
    // nejake menim na fortressy
    vector<bool> fortress = bad;
    queue<int> q;
    REP(i, g.n) {
        if (fortress[i]) continue;
        int good = 0;
        for (auto id : g.adj[i]) {
            edge e = g.edges[id];
            int other = i ^ e.src ^e.dest;
            if (!fortress[other]) good++;
        }
        if ((double) good / (double) g.adj[i].size() < x) q.push(i); // theoretically add EPS, cause doubles suck
    }
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int good = 0;
        for(auto id : g.adj[v]){
            edge e = g.edges[id];
            int other = e.src ^ e.dest ^ v;
            if(!fortress[other]) good++;
        }
        if((double) good / (double) g.adj[v].size() < x){
            fortress[v] = true;
            for(auto id : g.adj[v]){
                edge e = g.edges[id];
                int other = e.src ^ e.dest ^ v;
                if(!fortress[other]) q.push(other);
            }
        }
    }
    if(!construct){
        bool can = false;
        REP(i, g.n){
            if(!fortress[i]) can = true;
        }
        return can;
    }
    else{
        REP(i, g.n){
            if(!fortress[i]) ans.pb(i);
        }
        return true;
    }
}
double solve(undigraph &g){
    double l = 0;
    double r = 1;
    int cnt = 0;
    vi temp;
    double ans = 0;
    while(cnt < 20){
        double m = (l+r)/2;
        if(check(m, g, temp, false)){
            l = m;
            ans = m;
        }
        else r = m;
        cnt++;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m,k; cin >> n >> m >> k;
    bad.resize(n);
    undigraph g(n);
    REP(i, k){
        int x; cin >> x;
        x--; bad[x] = true;
    }
    REP(i, m){
        int u, v; cin >> u >> v;
        u--; v--;
        g.add_edge(u, v, 1);
    }
    double maxratio = solve(g);
    vi ans;
    check(maxratio, g, ans, true);
    cout << ans.size() << "\n";
    REP(i, ans.size()) cout << ans[i]+1 << " ";
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define MINF -(int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535
#define ff first
#define ss second

#ifdef DEBUG
#define DBG if(1)
#else
#define DBG if(0)
#endif

#define dbg(x) cout << "(" << #x << " : " << x << ")" << endl;

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template<class T>
ostream& operator<<(ostream& out, const vector<T> &v){
    out << "[";
    REP(i, v.size()) out << v[i] << ", ";
    out << "]";
    return out;
}
class edge{
    public:
        int src, dest;
        ll w;
        edge(int from, int to, ll weight){
            src = from;
            dest = to;
            w = weight;
        }
    };
class undigraph{
    public:
        int n;
        vector<edge> edges;
        vector<vi> adj;
        undigraph(int n){
            this->n = n;
            adj.resize(n);
        }
        void add_edge(int u, int v, ll w){
            edges.pb(edge(u, v, w));
            int id = edges.size()-1;
            adj[u].pb(id);
            adj[v].pb(id);
        }
    };
vector<bool> bad;
bool check(double x, undigraph &g, vi &ans, bool construct){
    // nejake menim na fortressy
    vector<bool> fortress = bad;
    queue<int> q;
    REP(i, g.n) {
        if (fortress[i]) continue;
        int good = 0;
        for (auto id : g.adj[i]) {
            edge e = g.edges[id];
            int other = i ^ e.src ^e.dest;
            if (!fortress[other]) good++;
        }
        if ((double) good / (double) g.adj[i].size() < x) q.push(i); // theoretically add EPS, cause doubles suck
    }
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int good = 0;
        for(auto id : g.adj[v]){
            edge e = g.edges[id];
            int other = e.src ^ e.dest ^ v;
            if(!fortress[other]) good++;
        }
        if((double) good / (double) g.adj[v].size() < x){
            fortress[v] = true;
            for(auto id : g.adj[v]){
                edge e = g.edges[id];
                int other = e.src ^ e.dest ^ v;
                if(!fortress[other]) q.push(other);
            }
        }
    }
    if(!construct){
        bool can = false;
        REP(i, g.n){
            if(!fortress[i]) can = true;
        }
        return can;
    }
    else{
        REP(i, g.n){
            if(!fortress[i]) ans.pb(i);
        }
        return true;
    }
}
double solve(undigraph &g){
    double l = 0;
    double r = 1;
    int cnt = 0;
    vi temp;
    double ans = 0;
    while(cnt < 30){
        double m = (l+r)/2;
        if(check(m, g, temp, false)){
            l = m;
            ans = m;
        }
        else r = m;
        cnt++;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m,k; cin >> n >> m >> k;
    bad.resize(n);
    undigraph g(n);
    REP(i, k){
        int x; cin >> x;
        x--; bad[x] = true;
    }
    REP(i, m){
        int u, v; cin >> u >> v;
        u--; v--;
        g.add_edge(u, v, 1);
    }
    double maxratio = solve(g);
    vi ans;
    check(maxratio, g, ans, true);
    cout << ans.size() << "\n";
    REP(i, ans.size()) cout << ans[i]+1 << " ";
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define MINF -(int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535
#define ff first
#define ss second

#ifdef DEBUG
#define DBG if(1)
#else
#define DBG if(0)
#endif

#define dbg(x) cout << "(" << #x << " : " << x << ")" << endl;

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template<class T>
ostream& operator<<(ostream& out, const vector<T> &v){
    out << "[";
    REP(i, v.size()) out << v[i] << ", ";
    out << "]";
    return out;
}
class edge{
    public:
        int src, dest;
        ll w;
        edge(int from, int to, ll weight){
            src = from;
            dest = to;
            w = weight;
        }
    };
class undigraph{
    public:
        int n;
        vector<edge> edges;
        vector<vi> adj;
        undigraph(int n){
            this->n = n;
            adj.resize(n);
        }
        void add_edge(int u, int v, ll w){
            edges.pb(edge(u, v, w));
            int id = edges.size()-1;
            adj[u].pb(id);
            adj[v].pb(id);
        }
    };
vector<bool> bad;
bool check(double x, undigraph &g, vi &ans, bool construct){
    // nejake menim na fortressy
    vector<bool> fortress = bad;
    queue<int> q;
    REP(i, g.n) {
        if (fortress[i]) continue;
        int good = 0;
        for (auto id : g.adj[i]) {
            edge e = g.edges[id];
            int other = i ^ e.src ^e.dest;
            if (!fortress[other]) good++;
        }
        if ((double) good / (double) g.adj[i].size() < x) q.push(i); // theoretically add EPS, cause doubles suck
    }
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int good = 0;
        for(auto id : g.adj[v]){
            edge e = g.edges[id];
            int other = e.src ^ e.dest ^ v;
            if(!fortress[other]) good++;
        }
        if((double) good / (double) g.adj[v].size() < x){
            fortress[v] = true;
            for(auto id : g.adj[v]){
                edge e = g.edges[id];
                int other = e.src ^ e.dest ^ v;
                if(!fortress[other]) q.push(other);
            }
        }
    }
    if(!construct){
        bool can = false;
        REP(i, g.n){
            if(!fortress[i]) can = true;
        }
        return can;
    }
    else{
        REP(i, g.n){
            if(!fortress[i]) ans.pb(i);
        }
        return true;
    }
}
double solve(undigraph &g){
    double l = 0;
    double r = 1;
    int cnt = 0;
    vi temp;
    double ans = 0;
    while(cnt < 50){
        double m = (l+r)/2;
        if(check(m, g, temp, false)){
            l = m;
            ans = m;
        }
        else r = m;
        cnt++;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m,k; cin >> n >> m >> k;
    bad.resize(n);
    undigraph g(n);
    REP(i, k){
        int x; cin >> x;
        x--; bad[x] = true;
    }
    REP(i, m){
        int u, v; cin >> u >> v;
        u--; v--;
        g.add_edge(u, v, 1);
    }
    double maxratio = solve(g);
    vi ans;
    check(maxratio, g, ans, true);
    cout << ans.size() << "\n";
    REP(i, ans.size()) cout << ans[i]+1 << " ";
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define MINF -(int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535
#define ff first
#define ss second

#ifdef DEBUG
#define DBG if(1)
#else
#define DBG if(0)
#endif

#define dbg(x) cout << "(" << #x << " : " << x << ")" << endl;

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template<class T>
ostream& operator<<(ostream& out, const vector<T> &v){
    out << "[";
    REP(i, v.size()) out << v[i] << ", ";
    out << "]";
    return out;
}
class fraction{
    public:
        ll top, bot;
        fraction(ll top, ll bot){
            this->top = top;
            this->bot = bot;
        }
    };
bool operator < (fraction lhs, fraction rhs){
    lhs.top*=(rhs.bot);
    rhs.top*=(lhs.bot);
    return lhs.top < rhs.top;
}
class edge{
    public:
        int src, dest;
        ll w;
        edge(int from, int to, ll weight){
            src = from;
            dest = to;
            w = weight;
        }
    };
class undigraph{
    public:
        int n;
        vector<edge> edges;
        vector<vi> adj;
        undigraph(int n){
            this->n = n;
            adj.resize(n);
        }
        void add_edge(int u, int v, ll w){
            edges.pb(edge(u, v, w));
            int id = edges.size()-1;
            adj[u].pb(id);
            adj[v].pb(id);
        }
    };
vector<bool> bad;
bool check(fraction x, undigraph &g, vi &ans, bool construct){
    // nejake menim na fortressy
    vector<bool> fortress = bad;
    queue<int> q;
    REP(i, g.n) {
        if (fortress[i]) continue;
        int good = 0;
        for (auto id : g.adj[i]) {
            edge e = g.edges[id];
            int other = i ^ e.src ^e.dest;
            if (!fortress[other]) good++;
        }
        fraction ratio(good, g.adj[i].size());
        if (ratio < x) q.push(i); // theoretically add EPS, cause doubles suck
    }
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int good = 0;
        for(auto id : g.adj[v]){
            edge e = g.edges[id];
            int other = e.src ^ e.dest ^ v;
            if(!fortress[other]) good++;
        }
        fraction ratio(good, g.adj[v].size());
        if(ratio < x){
            fortress[v] = true;
            for(auto id : g.adj[v]){
                edge e = g.edges[id];
                int other = e.src ^ e.dest ^ v;
                if(!fortress[other]) q.push(other);
            }
        }
    }
    if(!construct){
        bool can = false;
        REP(i, g.n){
            if(!fortress[i]) can = true;
        }
        return can;
    }
    else{
        REP(i, g.n){
            if(!fortress[i]) ans.pb(i);
        }
        return true;
    }
}
vector<fraction> possible_fractions;
fraction solve(undigraph &g){
    int l = 0;
    int r = possible_fractions.size()-1;
    int cnt = 0;
    vi temp;
    fraction ans = fraction(0, 1);
    while(l<=r){
        int m = (l+r)/2;
        if(check(possible_fractions[m], g, temp, false)){
            l = m + 1;
            ans = possible_fractions[m];
        }
        else r = m-1;
    }
    return ans;
}
// ocividne wa alebo tle ak zmenim cnt limit
// skusime ist cez vsetky mozne zlomky -> pre kazdy vrchol, pridam do setu vsetky x / pocet susedov
// takychto zlomkov tam bude radovo m
// snad to bude AC :)
// su tam cisto precision issues xd
// double su broken, treba legit zlomky pouzit
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m,k; cin >> n >> m >> k;
    bad.resize(n);
    undigraph g(n);
    REP(i, k){
        int x; cin >> x;
        x--; bad[x] = true;
    }
    REP(i, m){
        int u, v; cin >> u >> v;
        u--; v--;
        g.add_edge(u, v, 1);
    }
    possible_fractions.pb(fraction(0, 1));
    possible_fractions.pb(fraction(1, 1));
    REP(i, n) {
        FOR(j, 1, (int)g.adj[i].size()-1, 1){
            possible_fractions.pb(fraction(j, g.adj[i].size()));
        }
    }
    sort(possible_fractions.begin(), possible_fractions.end());
    fraction maxratio = solve(g);
    vi ans;
    check(maxratio, g, ans, true);
    cout << ans.size() << "\n";
    REP(i, ans.size()) cout << ans[i]+1 << " ";
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define MINF -(int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535
#define ff first
#define ss second

#ifdef DEBUG
#define DBG if(1)
#else
#define DBG if(0)
#endif

#define dbg(x) cout << "(" << #x << " : " << x << ")" << endl;

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template<class T>
ostream& operator<<(ostream& out, const vector<T> &v){
    out << "[";
    REP(i, v.size()) out << v[i] << ", ";
    out << "]";
    return out;
}
class edge{
    public:
        int src, dest;
        ll w;
        edge(int from, int to, ll weight){
            src = from;
            dest = to;
            w = weight;
        }
    };
class undigraph{
    public:
        int n;
        vector<edge> edges;
        vector<vi> adj;
        undigraph(int n){
            this->n = n;
            adj.resize(n);
        }
        void add_edge(int u, int v, ll w){
            edges.pb(edge(u, v, w));
            int id = edges.size()-1;
            adj[u].pb(id);
            adj[v].pb(id);
        }
    };
vector<bool> bad;
bool check(double x, undigraph &g, vi &ans, bool construct){
    // nejake menim na fortressy
    vector<bool> fortress = bad;
    queue<int> q;
    REP(i, g.n) {
        if (fortress[i]) continue;
        int good = 0;
        for (auto id : g.adj[i]) {
            edge e = g.edges[id];
            int other = i ^ e.src ^e.dest;
            if (!fortress[other]) good++;
        }
        if ((double) good / (double) g.adj[i].size() < x) q.push(i); // theoretically add EPS, cause doubles suck
    }
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int good = 0;
        for(auto id : g.adj[v]){
            edge e = g.edges[id];
            int other = e.src ^ e.dest ^ v;
            if(!fortress[other]) good++;
        }
        if((double) good / (double) g.adj[v].size() < x){
            fortress[v] = true;
            for(auto id : g.adj[v]){
                edge e = g.edges[id];
                int other = e.src ^ e.dest ^ v;
                if(!fortress[other]) q.push(other);
            }
        }
    }
    if(!construct){
        bool can = false;
        REP(i, g.n){
            if(!fortress[i]) can = true;
        }
        return can;
    }
    else{
        REP(i, g.n){
            if(!fortress[i]) ans.pb(i);
        }
        return true;
    }
}
double solve(undigraph &g){
    double l = 0;
    double r = 1;
    int cnt = 0;
    vi temp;
    double ans = 0;
    while(cnt < 70){
        double m = (l+r)/2;
        if(check(m, g, temp, false)){
            l = m;
            ans = m;
        }
        else r = m;
        cnt++;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m,k; cin >> n >> m >> k;
    bad.resize(n);
    undigraph g(n);
    REP(i, k){
        int x; cin >> x;
        x--; bad[x] = true;
    }
    REP(i, m){
        int u, v; cin >> u >> v;
        u--; v--;
        g.add_edge(u, v, 1);
    }
    double maxratio = solve(g);
    vi ans;
    check(maxratio, g, ans, true);
    cout << ans.size() << "\n";
    REP(i, ans.size()) cout << ans[i]+1 << " ";
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define MINF -(int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535
#define ff first
#define ss second

#ifdef DEBUG
#define DBG if(1)
#else
#define DBG if(0)
#endif

#define dbg(x) cout << "(" << #x << " : " << x << ")" << endl;

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template<class T>
ostream& operator<<(ostream& out, const vector<T> &v){
    out << "[";
    REP(i, v.size()) out << v[i] << ", ";
    out << "]";
    return out;
}
class edge{
    public:
        int src, dest;
        ll w;
        edge(int from, int to, ll weight){
            src = from;
            dest = to;
            w = weight;
        }
    };
class undigraph{
    public:
        int n;
        vector<edge> edges;
        vector<vi> adj;
        undigraph(int n){
            this->n = n;
            adj.resize(n);
        }
        void add_edge(int u, int v, ll w){
            edges.pb(edge(u, v, w));
            int id = edges.size()-1;
            adj[u].pb(id);
            adj[v].pb(id);
        }
    };
vector<bool> bad;
bool check(double x, undigraph &g, vi &ans, bool construct){
    // nejake menim na fortressy
    vector<bool> fortress = bad;
    queue<int> q;
    REP(i, g.n) {
        if (fortress[i]) continue;
        int good = 0;
        for (auto id : g.adj[i]) {
            edge e = g.edges[id];
            int other = i ^ e.src ^e.dest;
            if (!fortress[other]) good++;
        }
        if ((double) good / (double) g.adj[i].size() < x) q.push(i); // theoretically add EPS, cause doubles suck
    }
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int good = 0;
        for(auto id : g.adj[v]){
            edge e = g.edges[id];
            int other = e.src ^ e.dest ^ v;
            if(!fortress[other]) good++;
        }
        if((double) good / (double) g.adj[v].size() < x){
            fortress[v] = true;
            for(auto id : g.adj[v]){
                edge e = g.edges[id];
                int other = e.src ^ e.dest ^ v;
                if(!fortress[other]) q.push(other);
            }
        }
    }
    if(!construct){
        bool can = false;
        REP(i, g.n){
            if(!fortress[i]) can = true;
        }
        return can;
    }
    else{
        REP(i, g.n){
            if(!fortress[i]) ans.pb(i);
        }
        return true;
    }
}
vector<double> possible_fractions;
double solve(undigraph &g){
    int l = 0;
    int r = possible_fractions.size()-1;
    int cnt = 0;
    vi temp;
    double ans = 0;
    while(l<=r){
        int m = (l+r)/2;
        if(check(possible_fractions[m], g, temp, false)){
            l = m + 1;
            ans = possible_fractions[m];
        }
        else r = m-1;
    }
    return ans;
}
// ocividne wa alebo tle ak zmenim cnt limit
// skusime ist cez vsetky mozne zlomky -> pre kazdy vrchol, pridam do setu vsetky x / pocet susedov
// takychto zlomkov tam bude radovo m
// snad to bude AC :)
// su tam cisto precision issues xd
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m,k; cin >> n >> m >> k;
    bad.resize(n);
    undigraph g(n);
    REP(i, k){
        int x; cin >> x;
        x--; bad[x] = true;
    }
    REP(i, m){
        int u, v; cin >> u >> v;
        u--; v--;
        g.add_edge(u, v, 1);
    }
    possible_fractions.pb(0);
    possible_fractions.pb(1-EPS);
    REP(i, n) {
        FOR(j, 1, (int)g.adj[i].size()-1, 1){
            possible_fractions.pb((double)j / (double)g.adj[i].size() - EPS);
        }
    }
    sort(possible_fractions.begin(), possible_fractions.end());
    double maxratio = solve(g);
    vi ans;
    check(maxratio, g, ans, true);
    cout << ans.size() << "\n";
    REP(i, ans.size()) cout << ans[i]+1 << " ";
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define MINF -(int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535
#define ff first
#define ss second

#ifdef DEBUG
#define DBG if(1)
#else
#define DBG if(0)
#endif

#define dbg(x) cout << "(" << #x << " : " << x << ")" << endl;

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U> &cont) {
    out << "{";
    for( const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template<class T>
ostream& operator<<(ostream& out, const vector<T> &v){
    out << "[";
    REP(i, v.size()) out << v[i] << ", ";
    out << "]";
    return out;
}
class fraction{
    public:
        ll top, bot;
        fraction(ll top, ll bot){
            this->top = top;
            this->bot = bot;
        }
    };
bool operator < (fraction lhs, fraction rhs){
    lhs.top*=(rhs.bot);
    rhs.top*=(lhs.bot);
    return lhs.top < rhs.top;
}
class edge{
    public:
        int src, dest;
        ll w;
        edge(int from, int to, ll weight){
            src = from;
            dest = to;
            w = weight;
        }
    };
class undigraph{
    public:
        int n;
        vector<edge> edges;
        vector<vi> adj;
        undigraph(int n){
            this->n = n;
            adj.resize(n);
        }
        void add_edge(int u, int v, ll w){
            edges.pb(edge(u, v, w));
            int id = edges.size()-1;
            adj[u].pb(id);
            adj[v].pb(id);
        }
    };
vector<bool> bad;
bool check(fraction x, undigraph &g, vi &ans, bool construct){
    // nejake menim na fortressy
    vector<bool> fortress = bad;
    queue<int> q;
    REP(i, g.n) {
        if (fortress[i]) continue;
        int good = 0;
        for (auto id : g.adj[i]) {
            edge e = g.edges[id];
            int other = i ^ e.src ^e.dest;
            if (!fortress[other]) good++;
        }
        fraction ratio(good, g.adj[i].size());
        if (ratio < x) q.push(i);
    }
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int good = 0;
        for(auto id : g.adj[v]){
            edge e = g.edges[id];
            int other = e.src ^ e.dest ^ v;
            if(!fortress[other]) good++;
        }
        fraction ratio(good, g.adj[v].size());
        if(ratio < x){
            fortress[v] = true;
            for(auto id : g.adj[v]){
                edge e = g.edges[id];
                int other = e.src ^ e.dest ^ v;
                if(!fortress[other]) q.push(other);
            }
        }
    }
    if(!construct){
        bool can = false;
        REP(i, g.n){
            if(!fortress[i]) can = true;
        }
        return can;
    }
    else{
        REP(i, g.n){
            if(!fortress[i]) ans.pb(i);
        }
        return true;
    }
}
vector<fraction> possible_fractions;
fraction solve(undigraph &g){
    int l = 0;
    int r = possible_fractions.size()-1;
    int cnt = 0;
    vi temp;
    fraction ans = fraction(0, 1);
    while(l<=r){
        int m = (l+r)/2;
        if(check(possible_fractions[m], g, temp, false)){
            l = m + 1;
            ans = possible_fractions[m];
        }
        else r = m-1;
    }
    return ans;
}
// ocividne wa alebo tle ak zmenim cnt limit
// skusime ist cez vsetky mozne zlomky -> pre kazdy vrchol, pridam do setu vsetky x / pocet susedov
// takychto zlomkov tam bude radovo m
// snad to bude AC :)
// su tam cisto precision issues xd
// double su broken, treba legit zlomky pouzit
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m,k; cin >> n >> m >> k;
    bad.resize(n);
    undigraph g(n);
    REP(i, k){
        int x; cin >> x;
        x--; bad[x] = true;
    }
    REP(i, m){
        int u, v; cin >> u >> v;
        u--; v--;
        g.add_edge(u, v, 1);
    }
    possible_fractions.pb(fraction(0, 1));
    possible_fractions.pb(fraction(1, 1));
    REP(i, n) {
        FOR(j, 1, (int)g.adj[i].size(), 1){
            possible_fractions.pb(fraction(j, g.adj[i].size()));
        }
    }
    sort(possible_fractions.begin(), possible_fractions.end());
    fraction maxratio = solve(g);
    vi ans;
    check(maxratio, g, ans, true);
    cout << ans.size() << "\n";
    REP(i, ans.size()) cout << ans[i]+1 << " ";
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

struct rac {
	ll p, q;

	bool operator< (rac b) const {
		return p * b.q < q * b.p;
	}

	bool operator== (rac b) const {
		return p * b.q == q * b.p;
	}
};

int n, k, m;
basic_string<int> e[100005];
int v[100005], g[100005], v0[100005];

rac f1() {
	set<pair<rac, int>> s;

	for (int i=1; i<=n; i++)
		v[i] = v0[i];
	for (int i=1; i<=n; i++) {

		if (v[i]) {
			g[i] = 0;
			for (int y : e[i])
				if (v[y])
					g[i]++;
			s.insert({{g[i], (int)e[i].size()}, i});
		}
	}
	rac opt = s.begin()->first;
	while (s.size()) {
		auto it = s.begin();
		opt = max(opt, it->first);
		// ce brisemo cvor x
		int x = it->second;
		v[x] = 0;
		s.erase(it);
		for (int y : e[x]) {
			if (v[y] == 0)
				continue;
			s.erase({{g[y], (int)e[y].size()}, y});
			g[y]--;
			s.insert({{g[y], (int)e[y].size()}, y});
		}
	}

	return opt;
}

void f2(rac opt) {
	set<pair<rac, int>> s;

	for (int i=1; i<=n; i++)
		v[i] = v0[i];
	for (int i=1; i<=n; i++) {
		g[i] = 0;
		for (int y : e[i])
			if (v[y])
				g[i]++;
		s.insert({{g[i], (int)e[i].size()}, i});
	}

	while (s.size()) {

		if (opt == s.begin()->first) {
			basic_string<int> z;
			for (int i=1; i<=n; i++)
				if (v[i])
					z += i;
			cout << z.size() << '\n';
			for (int x : z)
				cout << x << ' ';
			cout << '\n';
			exit(0);
		}

		auto it = s.begin();
		// ce brisemo cvor x
		int x = it->second;
		v[x] = 0;
		s.erase(it);
		for (int y : e[x]) {
			if (v[y] == 0)
				continue;
			s.erase({{g[y], (int)e[y].size()}, y});
			g[y]--;
			s.insert({{g[y], (int)e[y].size()}, y});
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> m >> k;
	for (int i=1; i<=n; i++)
		v0[i] = 1;
	for (int i=0; i<k; i++) {
		int x;
		cin >> x;
		v0[x] = 0;
	}
	for (int i=0; i<m; i++) {
		int u, v;
		cin >> u >> v;
		e[u] += v;
		e[v] += u;
	}

	f2(f1());
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

struct rac {
	ll p, q;

	bool operator< (rac b) const {
		return p * b.q < q * b.p;
	}

	bool operator== (rac b) const {
		return p * b.q == q * b.p;
	}
};

int n, k, m;
basic_string<int> e[100005];
int v[100005], g[100005], v0[100005];

rac f1() {
	set<pair<rac, int>> s;

	for (int i=1; i<=n; i++)
		v[i] = v0[i];
	for (int i=1; i<=n; i++) {
		if (v[i]) {
			g[i] = 0;
			for (int y : e[i])
				if (v[y])
					g[i]++;
			s.insert({{g[i], (int)e[i].size()}, i});
		}
	}
	rac opt = s.begin()->first;
	while (s.size()) {
		auto it = s.begin();
		opt = max(opt, it->first);
		// ce brisemo cvor x
		int x = it->second;
		v[x] = 0;
		s.erase(it);
		for (int y : e[x]) {
			if (v[y] == 0)
				continue;
			s.erase({{g[y], (int)e[y].size()}, y});
			g[y]--;
			s.insert({{g[y], (int)e[y].size()}, y});
		}
	}

	return opt;
}

void f2(rac opt) {
	set<pair<rac, int>> s;

	for (int i=1; i<=n; i++)
		v[i] = v0[i];
	for (int i=1; i<=n; i++) {
		if (v[i]) {
			g[i] = 0;
			for (int y : e[i])
				if (v[y])
					g[i]++;
			s.insert({{g[i], (int)e[i].size()}, i});
		}
	}

	while (s.size()) {

		if (opt == s.begin()->first) {
			basic_string<int> z;
			for (int i=1; i<=n; i++)
				if (v[i])
					z += i;
			cout << z.size() << '\n';
			for (int x : z)
				cout << x << ' ';
			cout << '\n';
			exit(0);
		}

		auto it = s.begin();
		// ce brisemo cvor x
		int x = it->second;
		v[x] = 0;
		s.erase(it);
		for (int y : e[x]) {
			if (v[y] == 0)
				continue;
			s.erase({{g[y], (int)e[y].size()}, y});
			g[y]--;
			s.insert({{g[y], (int)e[y].size()}, y});
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> m >> k;
	for (int i=1; i<=n; i++)
		v0[i] = 1;
	for (int i=0; i<k; i++) {
		int x;
		cin >> x;
		v0[x] = 0;
	}
	for (int i=0; i<m; i++) {
		int u, v;
		cin >> u >> v;
		e[u] += v;
		e[v] += u;
	}

	f2(f1());
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 2000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m, k;
int Q[110000];
int sosed[110000];
int badso[110000];
bool  ban[110000];
set<int> gr[110000];
set<pair<double, int>> WER;
vector<int> DEL;

void under()
{
    double minz = WER.begin()->X;
    while (WER.size() && WER.begin()->X - minz < 1e-11) {
        int  minv = WER.begin()->Y;
        DEL.PB(minv);
        WER.erase(WER.begin());
        for(set<int>::iterator it=gr[minv].begin(); it!=gr[minv].end(); it++) {
            int w = *it;
            WER.erase(MP((gr[w].size()+.0)/sosed[w], w));
            gr[w].erase(minv);
            WER.insert(MP((gr[w].size()+.0)/sosed[w], w));
        }
        gr[minv].clear();

    }
    if (WER.size()) {DEL.clear(); under();}
    else{
        cout<<DEL.size()<<"\n";
        For(i,0,DEL.size())
        {
            cout<<DEL[i]+1<<" ";
        }
    }
}

void main()
{
    cin>>n>>k;
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 2000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m, k;
int Q[110000];
int sosed[110000];
int badso[110000];
bool  ban[110000];
set<int> gr[110000];
set<pair<double, int>> WER;
vector<int> DEL;

void under()
{
    double minz = WER.begin()->X;
    while (WER.size() && WER.begin()->X < minz + 1e-6) {
        int  minv = WER.begin()->Y;
        DEL.PB(minv);
        WER.erase(WER.begin());
        for(set<int>::iterator it=gr[minv].begin(); it!=gr[minv].end(); it++) {
            int w = *it;
            WER.erase(MP((gr[w].size()+.0)/sosed[w], w));
            gr[w].erase(minv);
            WER.insert(MP((gr[w].size()+.0)/sosed[w], w));
        }
        gr[minv].clear();

    }
    if (WER.size()) {DEL.clear(); under();}
    else{
        cout<<DEL.size()<<"\n";
        For(i,0,DEL.size())
        {
            cout<<DEL[i]+1<<" ";
        }
    }
}

void main()
{
    cin>>n>>k;
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 2000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m, k;
int Q[110000];
int sosed[110000];
int badso[110000];
bool  ban[110000];
set<int> gr[110000];
set<pair<double, int>> WER;
vector<int> DEL;

void under()
{
    double minz = WER.begin()->X;
    while (WER.size() && WER.begin()->X < minz + 1e-11) {
        int  minv = WER.begin()->Y;
        DEL.PB(minv);
        WER.erase(WER.begin());
        for(set<int>::iterator it=gr[minv].begin(); it!=gr[minv].end(); it++) {
            int w = *it;
            WER.erase(MP((gr[w].size()+.0)/sosed[w], w));
            gr[w].erase(minv);
            WER.insert(MP((gr[w].size()+.0)/sosed[w], w));
        }
        gr[minv].clear();

    }
    if (WER.size()) {DEL.clear(); under();}
    else{
        cout<<DEL.size()<<"\n";
        For(i,0,DEL.size())
        {
            cout<<DEL[i]+1<<" ";
        }
    }
}

void main()
{
    cin>>n>>k;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
const long long mod=1e9+9;
string s;
ll qpow(ll x,ll n,ll mod)
{
	ll res=1;
	while(n>0)
    {
    	if(n&1)res=res*x%mod;
    	x=x*x%mod;
    	n>>=1;
	}
	return res;
}
int main()
{
	ll n,a,b,k;
	cin>>n>>a>>b>>k;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.size();++i)
    {
    	int flag;
    	s[i]=='+'?flag=1:flag=-1;
    	ans=((ans+flag*qpow(a,n-i,mod)%mod*qpow(b,i,mod))%mod+mod)%mod;
	}

	ll q=qpow(b,k,mod),q1=qpow(a,k,mod);
	q1=qpow(q1,mod-2,mod);
	q=q*q1%mod;

	if(q==1)
	{
		ans*=(n+1)/k;
	}
	else {
		ans=(ans*(qpow(q,(n+1)/k,mod)-1)%mod*qpow(q-1,mod-2,mod)%mod+mod)%mod;

	}
	cout<<ans;
	return 0;
 }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll model = 1e9 + 9;
ll qpow(ll a, ll b, ll mod)
{
    ll ret = 1;
    while (b)
    {
        if (b & 1) ret = ret * a % mod;
        b >>= 1;
        a = a * a % mod;
    }
    return ret;
}
int main(void)
{
    int n, a, b, k;
    scanf("%d%d%d%d", &n, &a, &b, &k);
    char str[100005];
    scanf("%s", str);
    int i;
    ll res = 0;
    for (i = 0; i <= k - 1; i++)
    {
        if (str[i] == '-')
        {
            res = (res - qpow(a, n-i, model) * qpow(b, i, model) % model  + model) % model;
        }
        else
        {
            res = (res + qpow(a, n-i, model) * qpow(b, i, model) % model  + model) % model;
        }
    }
    ll t = qpow(b, k, model) * qpow(a, k * (model - 2), model) % model;
    if (t == 1)
    {
        res = res * ((n + 1) / k) % model;
    }
    else
    {
        res = res * (qpow(t, (n+1)/k, model) - 1) % model * qpow(t-1, model - 2, model) % model;
    }

    cout << res;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
const long long mod=1e9+9;
string s;
ll qpow(ll x,ll n,ll mod)
{
	ll res=1;
	while(n>0)
    {
    	if(n&1)res=res*x%mod;
    	x=x*x%mod;
    	n>>=1;
	}
	return res;
}
int main()
{
	ll n,a,b,k;
	cin>>n>>a>>b>>k;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.size();++i)
    {
    	int flag;
    	s[i]=='+'?flag=1:flag=-1;
     ans +=  (flag*qpow(a, n-i, mod) * qpow(b, i, mod) % mod  + mod) % mod;
	}

	ll q=qpow(b,k,mod)*qpow(a,k*(mod-2),mod)%mod;
	if(q==1)
	{
		ans*=(n+1)/k;
		ans%=mod;
	}
	else {
		ans=(ans*(qpow(q,(n+1)/k,mod)-1)%mod*qpow(q-1,mod-2,mod)%mod+mod)%mod;

	}
	cout<<ans;
	return 0;
 }


#include<iostream>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
const long long mod=1e9+9;
string s;
ll qpow(ll x,ll n,ll mod)
{
	ll res=1;
	while(n>0)
    {
    	if(n&1)res=res*x%mod;
    	x=x*x%mod;
    	n>>=1;
	}
	return res;
}
int main()
{
	ll n,a,b,k;
	cin>>n>>a>>b>>k;
    cin>>s;
    ll res=0;
    for(int i=0;i<s.size();++i)
    {
    	int flag;
    	s[i]=='+'?flag=1:flag=-1;
     res=  ((res+flag*qpow(a, n-i, mod) * qpow(b, i, mod) )% mod  + mod) % mod;
	}

ll t = qpow(b, k, mod) * qpow(a, k * (mod - 2), mod) % mod;
    if (t == 1)
    {
        res = res * ((n + 1) / k) % mod;
    }
    else
    {
        res = res * (qpow(t, (n+1)/k, mod) - 1) % mod * qpow(t-1, mod - 2, mod) % mod;
    }
    cout<<res;
	return 0;
 }


#include<iostream>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
const long long mod=1e9+9;
string s;
ll qpow(ll x,ll n,ll mod)
{
	ll res=1;
	while(n>0)
    {
    	if(n&1)res=res*x%mod;
    	x=x*x%mod;
    	n>>=1;
	}
	return res;
}
int main()
{
	ll n,a,b,k;
	cin>>n>>a>>b>>k;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.size();++i)
    {
    	int flag;
    	s[i]=='+'?flag=1:flag=-1;
    	ans+=(flag*qpow(a,n-i,mod)%mod*qpow(b,i,mod)%mod+mod)%mod;
	}

	ll q=qpow(b,k,mod),q1=qpow(a,k,mod);
	q1=qpow(q1,mod-2,mod);
	q=q*q1%mod;

	if(q==1)
	{
		ans*=(n+1)/k;
	}
	else {
		ans=(ans*(qpow(q,(n+1)/k,mod)-1)%mod*qpow(q-1,mod-2,mod)%mod+mod)%mod;

	}
	cout<<ans;
	return 0;
 }


#include <iostream>
using namespace std;
#define ll long long
const ll mod=1000000009;

ll powm(ll a,ll p){
   ll res=1LL;
   a%=mod;
   while(p>0){
      if(p&1){
         res=(res*a)%mod;
      }
      a=(a*a)%mod;
      p/=2;
   }
   return (res+mod)%mod;
}
int main() {
ll n,a,b,k,i,ans=0; string s;
cin>>n>>a>>b>>k>>s;
for(i=0;i<k;i++){
   ans=(ans+((s[i]=='+'?1:-1)*powm(a,n-i)*powm(b,i))%mod+mod)%mod;
}
ll q=(powm(a,mod-2)*(b%mod)+mod)%mod;
if(q==1){
   ans=(ans*(((n+1)/k)%mod))%mod;
}else{
   ans=(ans*(((powm(q,(n+1)/k)-1)*(powm(q-1,mod-2)))%mod))%mod;
}
cout<<ans;
    return 0;
}


#include <iostream>
using namespace std;
#define ll long long
const ll mod=1000000009;

ll powm(ll a,ll p){
   ll res=1LL;
   a%=mod;
   while(p>0){
      if(p&1){
         res=(res*a)%mod;
      }
      a=(a*a)%mod;
      p/=2;
   }
   return (res+mod)%mod;
}
int main() {
ll n,a,b,k,i,ans=0; string s;
cin>>n>>a>>b>>k>>s;
for(i=0;i<k;i++){
   ans=(ans+((s[i]=='+'?1:-1)*powm(a,n-i)*powm(b,i))%mod+mod)%mod;
}
ll q=(powm(a,mod-2)*(b%mod))%mod;
if(q==1){
   ans=(ans*(((n+1)/k)%mod))%mod;
}else{
   ans=(ans*(((powm(q,(n+1)/k)-1)*(powm(q-1,mod-2)))%mod))%mod;
}
cout<<ans;
    return 0;
}


#include <iostream>
using namespace std;
#define ll long long
const ll mod=1000000009;

ll powm(ll a,ll p){
   ll res=1LL;
   a%=mod;
   while(p>0){
      if(p&1){
         res=(res*a)%mod;
      }
      a=(a*a)%mod;
      p/=2;
   }
   return (res+mod)%mod;
}
int main() {
ll n,a,b,k,i,ans=0; string s;
cin>>n>>a>>b>>k>>s;
for(i=0;i<k;i++){
   ans=(ans+((s[i]=='+'?1:-1)*powm(a,n-i)*powm(b,i)+mod)%mod+mod)%mod;
}
ll q=(powm(a,mod-2)*(b%mod)+mod)%mod;
if(q==1){
   ans=(ans*(((n+1)/k)%mod)+mod)%mod;
}else{
   ans=(ans*(((powm(q,(n+1)/k)-1)*(powm(q-1,mod-2)))%mod)+mod)%mod;
}
cout<<ans;
    return 0;
}


#include <iostream>
using namespace std;
#define ll long long
const ll mod=1000000009;

ll powm(ll a,ll p){
   ll res=1LL;
   a%=mod;
   while(p>0){
      if(p&1){
         res=(res*a)%mod;
      }
      a=(a*a)%mod;
      p/=2;
   }
   return (res+mod)%mod;
}
int main() {
ll n,a,b,k,i,ans=0; string s;
cin>>n>>a>>b>>k>>s;
for(i=0;i<k;i++){
   ans=(ans+((s[i]=='+'?1:-1)*powm(a,n-i)*powm(b,i))%mod+mod)%mod;
}
ll q=(powm(a,mod-2)*(b%mod)+mod)%mod;
if(q==1){
   ans=(ans*(((n+1)/k)%mod)+mod)%mod;
}else{
   ans=(ans*(((powm(q,(n+1)/k)-1)*(powm(q-1,mod-2)))%mod)+mod)%mod;
}
cout<<ans;
    return 0;
}


#include <iostream>
using namespace std;
#define ll long long
const ll mod=1000000009;

ll powm(ll a,ll p){
   ll res=1LL;
   a%=mod;
   while(p>0){
      if(p&1){
         res=(res*a)%mod;
      }
      a=(a*a)%mod;
      p/=2;
   }
   return (res+mod)%mod;
}
int main() {
ll n,a,b,k,i,ans=0; string s;
cin>>n>>a>>b>>k>>s;
for(i=0;i<k;i++){
   ans=(ans+((s[i]=='+'?1:-1)*powm(a,n-i)*powm(b,i)+mod)%mod+mod)%mod;
}
ll q=(powm(a,mod-2)*(b%mod)+mod)%mod;
q=powm(q,k);
if(q==1){
   ans=(ans*(((n+1)/k)%mod)+mod)%mod;
}else{
   ans=(ans*(((powm(q,(n+1)/k)-1)*(powm(q-1,mod-2)))%mod)+mod)%mod;
}
cout<<ans;
    return 0;
}


#include <iostream>
using namespace std;
#define ll long long
const ll mod=1000000009;

ll powm(ll a,ll p){
   ll res=1LL;
   a%=mod;
   while(p>0){
      if(p&1){
         res=(res*a)%mod;
      }
      a=(a*a)%mod;
      p/=2;
   }
   return (res+mod)%mod;
}
int main() {
ll n,a,b,k,i,ans=0; string s;
cin>>n>>a>>b>>k>>s;
for(i=0;i<k;i++){
   ans=(ans+((s[i]=='+'?1:-1)*powm(a,n-i)*powm(b,i))%mod+mod)%mod;
}
ll q=(powm(a,mod-2)*(b%mod)+mod)%mod;
if(q==1){
   ans=(ans*(((n+1)/k)%mod)+mod)%mod;
}else{
   ans=(ans*(((powm(q,(n+1)/k)-1)*(powm(q-1,mod-2)))%mod))%mod;
}
cout<<ans;
    return 0;
}


#include<iostream>
using namespace std;

long long n,a,b,k;
long long re;
long long remain = 10e8+9;

long long power(long long a, long long b) {
    long long re = 1;
    long long tmp = a;
    do {
        if (b%2) re = re*tmp%remain;
        tmp = tmp*tmp%remain;
        b/=2;
    } while (b);
    return re;
}

int main() {
    cin >> n >> a >> b >> k;
    char s[k];
    cin >> s;
    int A[n+1], B[n+1];

    A[0] = B[0] = 1;
    for (int i=1; i<=n; i++) {
        A[i] = A[i-1]*a%remain;
        B[i] = B[i-1]*b%remain;
    }

    for (int i=0; i<=n; i++) {
        char c = s[i%k];
        if (c=='+') {
            re += A[n-i]*B[i];
        } else {
            re -= A[n-i]*B[i];
        }
        re %= remain;
    }
    if (re<0) re += remain;
    cout << re;
    return 0;
}


#include<iostream>
using namespace std;

long long n,a,b,k;
long long re;
long long remain = 10e8+9;

long long power(long long a, long long b) {
    long long re = 1;
    long long tmp = a;
    do {
        if (b%2) re = re*tmp%remain;
        tmp = tmp*tmp%remain;
        b/=2;
    } while (b);
    return re;
}

int main() {
    cin >> n >> a >> b >> k;
    char s[k];
    cin >> s;

    for (int i=0; i<=n; i++) {
        char c = s[i%k];
        if (c=='+') {
            re += power(a, n-i) * power(b, i);
        } else {
            re -= power(a, n-i) * power(b, i);
        }
        re %= remain;
    }
    if (re<0) re += remain;
    cout << re;
    return 0;
}


#include<iostream>
#include<math.h>
using namespace std;

int main() {
    int n,a,b,k;
    long long re = 0;
    long long remain = pow(10,9)+9;
    cin >> n >> a >> b >> k;
    char s[k];
    cin >> s;
    for (int i=0; i<=n; i++) {
        char c = s[i%k];
        if (c=='+') {
            re += round(pow(a,n-i))*round(pow(b,i));
        } else {
            re -= round(pow(a,n-i))*round(pow(b,i));
        }
        re %= remain;
        if (re<0) re += remain;
    }
    cout << re;
    return 0;
}


#include<iostream>
#include<math.h>
using namespace std;

int main() {
    int n,a,b,k;
    int re = 0;
    int remain = pow(10,9)+9;
    cin >> n >> a >> b >> k;
    char s[k];
    cin >> s;
    for (int i=0; i<=n; i++) {
        char c = s[i%k];
        if (c=='+') {
            re += round(pow(a,n-i))*round(pow(b,i));
        } else {
            re -= round(pow(a,n-i))*round(pow(b,i));
        }
        re %= remain;
        if (re<0) re += remain;
    }
    cout << re;
    return 0;
}


#include<iostream>
using namespace std;

long long n,a,b,k;
long long re;
long long remain = 10e8+9;

long long power(long long a, long long b) {
    long long re = 1;
    long long tmp = a;
    do {
        if (b%2) re = re*tmp%remain;
        tmp = tmp*tmp%remain;
        b/=2;
    } while (b);
    return re;
}

int main() {
    cin >> n >> a >> b >> k;
    char s[k];
    cin >> s;
    int A[n+1], B[n+1];

    A[0] = B[0] = 1;
    for (int i=1; i<=n; i++) {
        long long re = A[i-1]*a%remain;
        A[i] = (int) re;
        re = B[i-1]*b%remain;
        B[i] = (int) re;
    }

    for (int i=0; i<=n; i++) {
        char c = s[i%k];
        if (c=='+') {
            re += (long long) A[n-i]*B[i];
        } else {
            re -= (long long) A[n-i]*B[i];
        }
        re %= remain;
    }
    if (re<0) re += remain;
    cout << re;
    return 0;
}


#include<iostream>
using namespace std;

long long n,a,b,k;
long long re;
long long remain = 10e8+9;

long long power(long long a, long long b) {
    long long re = 1;
    long long tmp = a;
    do {
        if (b%2) re = re*tmp%remain;
        tmp = tmp*tmp%remain;
        b/=2;
    } while (b);
    return re;
}

int main() {
    cin >> n >> a >> b >> k;
    char s[k];
    cin >> s;

    for (int i=0; i<k; i++) {
        if (s[i]=='+') {
            re += power(a, n-i)*power(b, i)%remain;
        } else {
            re -= power(a, n-i)*power(b, i)%remain;
        }
        re = (re + remain)%remain;
    }

    int tmp = power(power(a,k), remain-2)*power(b, k)%remain;
    if (tmp==1) re = re*((n+1)/k)%remain;
    else re = re*power(tmp-1, remain-2)%remain*(power(tmp, (n+1)/k)-1)%remain;
    cout << re;
    return 0;
}


#include<iostream>
#include<math.h>
using namespace std;

int main() {
    int n,a,b,k;
    int re = 0;
    int remain = pow(10,9)+9;
    cin >> n >> a >> b >> k;
    char s[k];
    cin >> s;
    for (int i=0; i<=n; i++) {
        char c = s[i%k];
        if (c=='+') {
            re += round(pow(a,n-i))*round(pow(b,i));
        } else {
            re -= round(pow(a,n-i))*round(pow(b,i));
        }
        re %= remain;
    }
    if (re<0) re += remain;
    cout << re;
    return 0;
}


#include<iostream>
using namespace std;

long long n,a,b,k;
long long re;
long long remain = 10e8+9;

long long power(long long a, long long b) {
    long long re = 1;
    long long tmp = a;
    do {
        if (b%2) re = re*tmp%remain;
        tmp = tmp*tmp%remain;
        b/=2;
    } while (b);
    return re;
}

int main() {
    cin >> n >> a >> b >> k;
    char s[k];
    cin >> s;
    long long B = 1;

    for (int i=0; i<=n; i++) {
        char c = s[i%k];
        if (c=='+') {
            re += power(a, n-i) * B;
        } else {
            re -= power(a, n-i) * B;
        }
        re %= remain;
        B = B*b%remain;
    }
    if (re<0) re += remain;
    cout << re;
    return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define ll long long int
#define mod 1000000009

using namespace std;

ll po(ll a, ll b) {
    ll re=1;
    while(b)
    {
        if(b%2)
            re = (re*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return re;
}

int main()
{
    ll n,a,b,sum=0,ans,num,den;
    string s;
    ll k;
    cin>>n>>a>>b>>k;
    cin>>s;
    for(ll i=0;i<k;i++)
    {
        if(s[i]=='+')
            sum = (sum + ((po(a,k-i-1) * po(b,i))%mod))%mod;
        else
            sum = (sum - ((po(a,k-i-1) * po(b,i))%mod) + mod)%mod;
    }
    num = (po(a,n+1) - po(b,n+1) + mod)%mod;
    den = (po(a,k) - po(b,k) + mod)%mod;
    ans = (num * po(den, mod-2))%mod;
    if(a == b)
        ans = (po(a,n-k+1) * (n+1)/k)%mod;
    ans = ((ans * sum)%mod + mod)%mod;
    cout<<ans<<"\n";
    return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define ll long long int
#define mod 1000000009

using namespace std;

ll po(ll a, ll b) {
    ll re=1;
    while(b)
    {
        if(b%2)
            re = (re*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return re;
}

int main()
{
    ll n,a,b,sum=0,ans,num,den;
    string s;
    ll k;
    cin>>n>>a>>b>>k;
    cin>>s;
    for(ll i=0;i<k;i++)
    {
        if(s[i]=='+')
            sum = (sum + ((po(a,k-i-1) * po(b,i))%mod))%mod;
        else
            sum = (sum - ((po(a,k-i-1) * po(b,i))%mod) + mod)%mod;
    }
    num = (po(a,n+1) - po(b,n+1) + mod)%mod;
    den = (po(a,k) - po(b,k) + mod)%mod;
    ans = (num * po(den, mod-2))%mod;
    ans = ((ans * sum)%mod + mod)%mod;
    cout<<ans<<"\n";
    return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define ll long long int
#define mod 1000000009

using namespace std;

ll po(ll a, ll b) {
    ll re=1;
    while(b)
    {
        if(b%2)
            re = (re*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return re;
}

int main()
{
    ll n,a,b,sum=0,ans,num,den;
    string s;
    int k;
    cin>>n>>a>>b>>k;
    cin>>s;
    for(int i=0;i<k;i++)
    {
        if(s[i]=='+')
            sum = (sum + ((po(a,k-i-1) * po(b,i))%mod))%mod;
        else
            sum = (sum - ((po(a,k-i-1) * po(b,i))%mod))%mod;
    }
    num = (po(a,n+1) - po(b,n+1))%mod;
    den = (po(a,k) - po(b,k))%mod;
    ans = (num * po(den, mod-2))%mod;
    ans = ((ans * sum)%mod + mod)%mod;
    cout<<ans<<"\n";
    return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define ll long long int
#define mod 1000000009

using namespace std;

ll po(ll a, ll b) {
    ll re=1;
    while(b)
    {
        if(b%2)
            re = (re*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return re;
}

int main()
{
    ll n,a,b,sum=0,ans,num,den;
    string s;
    ll k;
    cin>>n>>a>>b>>k;
    cin>>s;
    for(ll i=0;i<k;i++)
    {
        if(s[i]=='+')
            sum = (sum + ((po(a,k-i-1) * po(b,i))%mod))%mod;
        else
            sum = (sum - ((po(a,k-i-1) * po(b,i))%mod) + mod)%mod;
    }
    num = (po(a,n+1) - po(b,n+1) + mod)%mod;
    den = (po(a,k) - po(b,k) + mod)%mod;
    ans = (num * po(den, mod-2))%mod;
    if(a == b)
        ans = (n+1)/k;
    ans = ((ans * sum)%mod + mod)%mod;
    cout<<ans<<"\n";
    return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define ll long long int
#define mod 1000000009

using namespace std;

ll po(ll a, ll b) {
    ll re=1;
    while(b)
    {
        if(b%2)
            re = (re*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return re;
}

int main()
{
    ll n,a,b,sum=0,ans,num,den;
    string s;
    ll k;
    cin>>n>>a>>b>>k;
    if(a>b)
        swap(a,b);
    cin>>s;
    for(ll i=0;i<k;i++)
    {
        if(s[i]=='+')
            sum = (sum + ((po(a,k-i-1) * po(b,i))%mod))%mod;
        else
            sum = (sum - ((po(a,k-i-1) * po(b,i))%mod) + mod)%mod;
    }
    num = (po(a,n+1) - po(b,n+1) + mod)%mod;
    den = (po(a,k) - po(b,k) + mod)%mod;
    ans = (num * po(den, mod-2))%mod;
    if(num == den)
        ans = 1;
    ans = ((ans * sum)%mod + mod)%mod;
    cout<<ans<<"\n";
    return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define ll long long int
#define mod 1000000009

using namespace std;

ll po(ll a, ll b) {
    ll re=1;
    while(b)
    {
        if(b%2)
            re = (re*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return re;
}

int main()
{
    ll n,a,b,sum=0,ans,num,den;
    string s;
    ll k;
    cin>>n>>a>>b>>k;
    cin>>s;
    for(ll i=0;i<k;i++)
    {
        if(s[i]=='+')
            sum = (sum + ((po(a,k-i-1) * po(b,i))%mod))%mod;
        else
            sum = (sum - ((po(a,k-i-1) * po(b,i))%mod) + mod)%mod;
    }
    num = (po(a,n+1) - po(b,n+1) + mod)%mod;
    den = (po(a,k) - po(b,k) + mod)%mod;
    ans = (num * po(den, mod-2))%mod;
    if(num == den)
        ans = 1;
    ans = ((ans * sum)%mod + mod)%mod;
    cout<<ans<<"\n";
    return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define ll long long int
#define mod 1000000009

using namespace std;

ll po(ll a, ll b) {
    ll re=1;
    while(b)
    {
        if(b%2)
            re = (re*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return re;
}

int main()
{
    ll n,a,b,sum=0,ans,num,den;
    string s;
    ll k;
    cin>>n>>a>>b>>k;
    cin>>s;
    for(ll i=0;i<k;i++)
    {
        if(s[i]=='+')
            sum = (sum + ((po(a,k-i-1) * po(b,i))%mod))%mod;
        else
            sum = (sum - ((po(a,k-i-1) * po(b,i))%mod) + mod)%mod;
    }
    num = (po(a,n+1) - po(b,n+1) + mod)%mod;
    den = (po(a,k) - po(b,k) + mod)%mod;
    ans = (num * po(den, mod-2))%mod;
    if(po(b,k) == po(po(a,mod-2),k))
        ans = (po(a,n-k+1) * (n+1)/k)%mod;
    ans = ((ans * sum)%mod + mod)%mod;
    cout<<ans<<"\n";
    return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define ll long long int
#define mod 1000000009

using namespace std;

ll po(ll a, ll b) {
    ll re=1;
    while(b)
    {
        if(b%2)
            re = (re*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return re;
}

int main()
{
    ll n,a,b,sum=0,ans,num,den;
    string s;
    ll k;
    cin>>n>>a>>b>>k;
    cin>>s;
    for(ll i=0;i<k;i++)
    {
        if(s[i]=='+')
            sum = (sum + ((po(a,k-i-1) * po(b,i))%mod))%mod;
        else
            sum = (sum - ((po(a,k-i-1) * po(b,i))%mod) + mod)%mod;
    }
    num = (po(a,n+1) - po(b,n+1) + mod)%mod;
    den = (po(a,k) - po(b,k) + mod)%mod;
    ans = (num * po(den, mod-2))%mod;
    if(a == b)
        ans = n+1;
    ans = ((ans * sum)%mod + mod)%mod;
    cout<<ans<<"\n";
    return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

#define MOD 1000000009

using namespace std;

typedef long long ll;

/*int Max(int a, int b)
{
	return a >= b ? a : b;
}

int main(void)
{
	int ans = 0;
	int n, A, B, C, T, unread = 0;
	cin >> n >> A >> B >> C >> T;
	for (int a = 1; a <= n; a = a + 1)
	{
		int ti, cmp, plus;
		cin >> ti;
		if (ti > T)
			ans += ti;
		else
		{
			int tmp;
			for (int b = ti + 1; b <= T; b = b + 1)
			{
				tmp = A + (b - ti) * (C - B);
				plus = Max(tmp, A);
			}
			cout << plus << endl;
			ans += plus;
		}
	}
	cout << ans;
	return 0;
}*/

ll Hope(int a, int p)
{
	ll r = 1, tmpa = a;
	while (p)
	{
		if (p & 1)
			r = (r * tmpa) % MOD;
		tmpa = (tmpa * a) % MOD;
		p = p >> 1;
	}

	return r;
}

int main(void)
{
	ios::sync_with_stdio(false);

	int n, k;
	ll mid, ans = 0, a, b, powa = 1, powb = 1;
	string pm;
	cin >> n >> a >> b >> k;
	cin >> pm;

	for (int i = 0; i <= n; i = i + 1)
	{
		powa = Hope(a, n - i);
		if (pm[i % k] == '-')
		{
			ans = ans - (powa * powb);
			while (ans < 0)
				ans += MOD;
			ans = ans % MOD;
		}
		else if (pm[i % k] == '+')
		{
			ans = (ans + powa * powb) % MOD;
		}
		powb = (powb * b) % MOD;
	}

	cout << ans;
	return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

#define MOD 1000000009

using namespace std;

typedef long long ll;

int main(void)
{
	ios::sync_with_stdio(false);

	int n, a, b, k;
	ll mid, ans = 0, powa = 1, powb = 1;
	string pm;
	cin >> n >> a >> b >> k;
	cin >> pm;

	for (int p = 0; p < n; p = p + 1)
	{
		powa = (powa * a) % MOD;
	}

	for (int i = 0; i <= n; i = i + 1)
	{
		if (pm[i % k] == '-')
		{
			ans = ans - (powa * powb);
			if (ans < 0)
				ans += MOD;
			ans = ans % MOD;
		}
		else if (pm[i % k] == '+')
		{
			ans = (ans + ((powa * powb) % MOD)) % MOD;
		}
		powa = (powa / a) % MOD;
		powb = (powb * b) % MOD;
	}

    cout << ans;
    return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

#define MOD 1000000009

using namespace std;

typedef long long ll;

int main(void)
{
	ios::sync_with_stdio(false);

	int n, a, b, k;
	ll mid, ans = 0, powa = 1, powb = 1;
	string pm;
	cin >> n >> a >> b >> k;
	cin >> pm;

	for (int p = 1; p <= n; p = p + 1)
	{
		powa = (powa * a) % MOD;
	}

	for (int i = 0; i <= n; i = i + 1)
	{
		if (pm[i % k] == '-')
		{
			ans = ans - (powa * powb);
			while (ans < 0)
				ans += MOD;
			ans = ans % MOD;
		}
		else if (pm[i % k] == '+')
		{
			ans = (ans + powa * powb) % MOD;
		}
		powa = (powa / a) % MOD;
		powb = (powb * b) % MOD;
	}

	cout << ans;
	return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

const int MOD = 9 + 1.0e+9;

using namespace std;

typedef long long ll;

ll Mod_Square(int x, int p)
{
	ll r = 1, tmp = x;

	while (p)
	{
		if (p & 1)
		{
			r = (r * tmp) % MOD;
		}
		p >>= 1;
		tmp = (tmp * tmp) % MOD;
	}
	return r;
}

int main(void)
{
	string op;
	int n, a, b, k, m, inv_a;
	ll tmpb = 1, unit;
	cin >> n >> a >> b >> k;
	cin >> op;
	m = (n + 1) / k;
	ll Z0 = 0, ans = 0, pow_a = Mod_Square(a, n);

	inv_a = Mod_Square(a, MOD - 2) % MOD;
	unit = Mod_Square(b, k);
	unit = (unit * Mod_Square(inv_a, k)) % MOD;

	for (int i = 0; i < k; i = i + 1)
	{
		ll tmp = pow_a;
		if (op[i] == '-')
			tmp = -pow_a;

		tmp = (tmp * tmpb) % MOD;
		Z0 = Z0 + tmp;

		Z0 = (Z0 + MOD) % MOD;

		tmpb = (tmpb * b) % MOD;
		pow_a = (pow_a * inv_a) % MOD;
	}
	ll tmpsum = 0, tmpu = unit;
	for (int i = 1; i <= m - 1; i += 1)
	{
		tmpsum = (tmpsum + tmpu) % MOD;
		tmpu = (tmpu * unit) % MOD;
	}
	ans = (Z0 * (1 + tmpsum)) % MOD;

	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

const int MOD = 9 + 1.0e+9;

using namespace std;

typedef long long ll;

int Max(int a, int b)
{
	return a >= b ? a : b;
}

ll Mod_Square(int x, int p)
{
	ll r = 1, tmp = x;

	while (p)
	{
		if (p & 1)
		{
			r = (r * tmp) % MOD;
		}
		p >>= 1;
		tmp = (tmp * tmp) % MOD;
	}
	return r;
}

int main(void)
{
	string op;
	int n, a, b, k, m;
	ll tmpb = 1, unit;
	cin >> n >> a >> b >> k;
	cin >> op;
	m = (n + 1) / k;
	ll Z0 = 0, ans = 0;

	unit = Mod_Square(b, k);
	unit = (unit * Mod_Square(a, MOD - 2)) % MOD;

	for (int i = 0; i < k; i = i + 1)
	{
		ll tmp = Mod_Square(a, n - i);
		if (op[i] == '-')
			tmp = -tmp;

		tmp = (tmp * tmpb);
		Z0 = Z0 + tmp;

		while (Z0 < 0)
			Z0 += MOD;

		Z0 = Z0 % MOD;
		tmpb = (tmpb * b) % MOD;
	}
	ll tmpsum = 0, tmpu = unit;
	for (int i = 1; i <= m - 1; i += 1)
	{
		tmpsum = (tmpsum + tmpu) % MOD;
		tmpu = (tmpu * unit) % MOD;
	}
	ans = (Z0 * (1 + tmpsum)) % MOD;

	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

#define MOD 1000000009

using namespace std;

typedef long long ll;

/*int Max(int a, int b)
{
	return a >= b ? a : b;
}

int main(void)
{
	int ans = 0;
	int n, A, B, C, T, unread = 0;
	cin >> n >> A >> B >> C >> T;
	for (int a = 1; a <= n; a = a + 1)
	{
		int ti, cmp, plus;
		cin >> ti;
		if (ti > T)
			ans += ti;
		else
		{
			int tmp;
			for (int b = ti + 1; b <= T; b = b + 1)
			{
				tmp = A + (b - ti) * (C - B);
				plus = Max(tmp, A);
			}
			cout << plus << endl;
			ans += plus;
		}
	}
	cout << ans;
	return 0;
}*/

ll Hope(int a, int p)
{
	ll r = 1, tmpa = a;
	while (p)
	{
		if (p & 1)
			r = (r * tmpa) % MOD;
		tmpa = (tmpa * a) % MOD;
		p = p >> 1;
	}

	return r;
}

int main(void)
{
	ios::sync_with_stdio(false);

	int n, k;
	ll mid, ans = 0, a, b, powa = 1, powb = 1;
	string pm;
	cin >> n >> a >> b >> k;
	cin >> pm;

	for (int i = 0; i <= n; i = i + 1)
	{
		powa = Hope(a, n - i);
		if (pm[i % k] == '-')
		{
			ans = ans - (powa * powb);
			while (ans < 0)
				ans += MOD;
			ans = ans % MOD;
		}
		else if (pm[i % k] == '+')
		{
			ans = (ans + powa * powb) % MOD;
		}
		cout << powa << ' ' << powb << endl;
		powb = (powb * b) % MOD;
	}

	cout << ans;
	return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

#define MOD 1000000009

using namespace std;

typedef long long ll;

/*int Max(int a, int b)
{
	return a >= b ? a : b;
}

int main(void)
{
	int ans = 0;
	int n, A, B, C, T, unread = 0;
	cin >> n >> A >> B >> C >> T;
	for (int a = 1; a <= n; a = a + 1)
	{
		int ti, cmp, plus;
		cin >> ti;
		if (ti > T)
			ans += ti;
		else
		{
			int tmp;
			for (int b = ti + 1; b <= T; b = b + 1)
			{
				tmp = A + (b - ti) * (C - B);
				plus = Max(tmp, A);
			}
			cout << plus << endl;
			ans += plus;
		}
	}
	cout << ans;
	return 0;
}*/

ll Hope(int a, int p)
{
	ll r = 1, tmpa = 1;
	while (p)
	{
		if (p & 1)
			r = (r * tmpa) % MOD;
		tmpa = (tmpa * a) % MOD;
		p = p >> 1;
	}

	return r;
}

int main(void)
{
	ios::sync_with_stdio(false);

	int n, k;
	ll mid, ans = 0, a, b, powa = 1, powb = 1;
	string pm;
	cin >> n >> a >> b >> k;
	cin >> pm;

	for (int i = 0; i <= n; i = i + 1)
	{
		powa = Hope(a, n - a);

		if (pm[i % k] == '-')
		{
			ans = ans - (powa * powb);
			while (ans < 0)
				ans += MOD;
			ans = ans % MOD;
		}
		else if (pm[i % k] == '+')
		{
			ans = (ans + powa * powb) % MOD;
		}
		powb = (powb * b) % MOD;
	}

	cout << ans;
	return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

#define MOD 1000000009

using namespace std;

typedef long long ll;

/*int Max(int a, int b)
{
	return a >= b ? a : b;
}

int main(void)
{
	int ans = 0;
	int n, A, B, C, T, unread = 0;
	cin >> n >> A >> B >> C >> T;
	for (int a = 1; a <= n; a = a + 1)
	{
		int ti, cmp, plus;
		cin >> ti;
		if (ti > T)
			ans += ti;
		else
		{
			int tmp;
			for (int b = ti + 1; b <= T; b = b + 1)
			{
				tmp = A + (b - ti) * (C - B);
				plus = Max(tmp, A);
			}
			cout << plus << endl;
			ans += plus;
		}
	}
	cout << ans;
	return 0;
}*/

ll Hope(int a, int p)
{
	ll r = 1, tmpa = a;
	while (p)
	{
		if (p & 1)
			r = (r * tmpa) % MOD;
		tmpa = (tmpa * a) % MOD;
		p = p >> 1;
	}

	return r;
}

vector<ll> powers(100001);

int main(void)
{
	ios::sync_with_stdio(false);

	int n, k;
	ll mid, ans = 0, a, b, powa = 1, powb = 1;
	string pm;
	cin >> n >> a >> b >> k;
	cin >> pm;

	for (int i = 0; i <= 100000; i = i + 1)
	{
		powers[i] = powa;
		powa = (powa * a) % MOD;
	}

	for (int i = 0; i <= n; i = i + 1)
	{
		if (pm[i % k] == '-')
		{
			ans = ans - (powers[n-i] * powb);
			while (ans < 0)
				ans += MOD;
			ans = ans % MOD;
		}
		else if (pm[i % k] == '+')
		{
			ans = (ans + powers[n-i] * powb) % MOD;
		}
		powb = (powb * b) % MOD;
	}

	cout << ans;
	return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

#define MOD 1000000009

using namespace std;

typedef long long ll;

int main(void)
{
	ios::sync_with_stdio(false);

	int n, a, b, k;
	ll mid, ans = 0, powa = 1, powb = 1;
	string pm;
	cin >> n >> a >> b >> k;
	cin >> pm;

	for (int p = 1; p <= n; p = p + 1)
	{
		powa = (powa * a) % MOD;
	}
	for (int i = 0; i <= n; i = i + 1)
	{
		if (pm[i % k] == '-')
		{
			ans = ans - (powa * powb);
			while (ans < 0)
				ans += MOD;
			ans = ans % MOD;
		}
		else if (pm[i % k] == '+')
		{
			ans = (ans + powa * powb) % MOD;
		}
		cout << powa << ' ' << powb << ' ' << ans << endl;
		powa = (powa / a) % MOD;
		powb = (powb * b) % MOD;
	}

	cout << ans;
	return 0;
}


#include <iostream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <map>

const int MOD = 9 + 1.0e+9;

using namespace std;

typedef long long ll;

ll Mod_Square(int x, int p)
{
	ll r = 1, tmp = x;

	while (p)
	{
		if (p & 1)
		{
			r = (r * tmp) % MOD;
		}
		p >>= 1;
		tmp = (tmp * tmp) % MOD;
	}
	return r;
}

int main(void)
{
	string op;
	int n, a, b, k, m, inv_a;
	ll tmpb = 1, unit;
	cin >> n >> a >> b >> k;
	cin >> op;
	m = (n + 1) / k;
	ll Z0 = 0, ans = 0, pow_a = Mod_Square(a, n);

	inv_a = Mod_Square(a, MOD - 2) % MOD;
	unit = Mod_Square(b, k);
	unit = (unit * Mod_Square(inv_a, k)) % MOD;

	for (int i = 0; i < k; i = i + 1)
	{
		ll tmp = pow_a;
		if (op[i] == '-')
			tmp = -pow_a;

		tmp = (tmp * tmpb) % MOD;
		Z0 = Z0 + tmp;

		Z0 = (Z0 + MOD) % MOD;

		tmpb = (tmpb * b) % MOD;
		pow_a = (pow_a * inv_a) % MOD;
	}

	if (unit == 1)
	{
		ans = (Z0 * m) % MOD;
	}
	else
	{
		int inv_u = Mod_Square(unit - 1, MOD - 2);
		ans = ((Z0 * (Mod_Square(unit, m) - 1)) % MOD * inv_u) % MOD;
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define ld long double
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define F first
#define S second
const int MOD=1000000000+9;
long long int inverse(long long int i){
    if(i==1) return 1;
    return (MOD - ((MOD/i)*inverse(MOD%i))%MOD+MOD)%MOD;
}
ll POW(ll a,ll b)
{
    if(b==0) return 1;
    if(b==1) return a%MOD;
    ll temp=POW(a,b/2);
    if(b%2==0) return (temp*temp)%MOD;
    else return (((temp*temp)%MOD)*a)%MOD;
}

int main()
{long long int n,a,b,k;
cin >>n>>a>>b>>k;
string s1;
cin >> s1;
if(a!=b)
{
long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=(POW(a,n-i)*POW(b,i))%MOD;
        sum=sum%MOD;
    }
else
{sum-=(POW(a,n-i)*POW(b,i))%MOD;
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int res,res1,res2,res3=(b*inverse(a))%MOD;
n++;
res=(POW(res3,n)-1+MOD)%MOD;
res1=(POW(res3,k)-1+MOD)%MOD;
long long int finres;
finres=((sum*res)%MOD*inverse(res1))%MOD;
cout<<finres<<"\n";}
else
{long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=POW(a,n);
        sum=sum%MOD;
    }
else
{sum-=POW(a,n);
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int finres=(((n+1)/k)%MOD*sum)%MOD;
    cout<<finres<<"\n";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define ld long double
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define F first
#define S second
const int MOD=1000000000+9;
long long int inverse(long long int i){
    if(i==1) return 1;
    return (MOD - ((MOD/i)*inverse(MOD%i))%MOD+MOD)%MOD;
}
ll POW(ll a,ll b)
{
    if(b==0) return 1;
    if(b==1) return a%MOD;
    ll temp=POW(a,b/2);
    if(b%2==0) return (temp*temp)%MOD;
    else return (((temp*temp)%MOD)*a)%MOD;
}

int main()
{long long int n,a,b,k;
cin >>n>>a>>b>>k;
string s1;
cin >> s1;
if(a!=b)
{
long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=(POW(a,k-i-1)*POW(b,i))%MOD;
        sum=sum%MOD;
    }
else
{sum-=(POW(a,k-i-1)*POW(b,i))%MOD;
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int res,res1,res2;
n++;
if(b>a)
{res=(POW(b,n)-POW(a,n))%MOD;
    if(res<0)
    res+=MOD;
    res1=(POW(b,k)-POW(a,k))%MOD;
    if(res1<0)
    res1+=MOD;

}
else
{res=(-POW(b,n)
+POW(a,n))%MOD;
    if(res<0)
    res+=MOD;
    res1=(-POW(b,k)+POW(a,k))%MOD;
    if(res1<0)
    res1+=MOD;

}
long long int finres;
finres=((sum*res)%MOD*inverse(res1))%MOD;
cout<<finres<<"\n";}
else
{long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=POW(a,n);
        sum=sum%MOD;
    }
else
{sum-=POW(a,n);
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int finres=((n+1)%MOD*sum)%MOD;
    cout<<finres<<"\n";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define ld long double
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define F first
#define S second
const int MOD=1000000000+9;
long long int inverse(long long int i){
    if(i==1) return 1;
    return (MOD - ((MOD/i)*inverse(MOD%i))%MOD+MOD)%MOD;
}
ll POW(ll a,ll b)
{
    if(b==0) return 1;
    if(b==1) return a%MOD;
    ll temp=POW(a,b/2);
    if(b%2==0) return (temp*temp)%MOD;
    else return (((temp*temp)%MOD)*a)%MOD;
}

int main()
{long long int n,a,b,k;
cin >>n>>a>>b>>k;
string s1;
cin >> s1;
if(a!=b)
{
long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=(POW(a,k-i-1)*POW(b,i))%MOD;
        sum=sum%MOD;
    }
else
{sum-=(POW(a,k-i-1)*POW(b,i))%MOD;
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int res,res1,res2;
n++;
if(b>a)
{res=(POW(b,n)-POW(a,n))%MOD;
    if(res<0)
    res+=MOD;
    res1=(POW(b,k)-POW(a,k))%MOD;
    if(res1<0)
    res1+=MOD;

}
else
{res=(-POW(b,n)
+POW(a,n))%MOD;
    if(res<0)
    res+=MOD;
    res1=(-POW(b,k)+POW(a,k))%MOD;
    if(res1<0)
    res1+=MOD;

}
long long int finres;
finres=((sum*res)%MOD)*inverse(res1))%MOD;
cout<<finres<<"\n";}
else
{long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=POW(a,n-i)
        sum=sum%MOD;
    }
else
{sum-=POW(a,n-i)
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int finres=((n+1)%MOD*sum)%MOD;
    cout<<finres<<"\n";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define ld long double
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define F first
#define S second
const int MOD=1000000000+9;
long long int inverse(long long int i){
    if(i==1) return 1;
    return (MOD - ((MOD/i)*inverse(MOD%i))%MOD+MOD)%MOD;
}
ll POW(ll a,ll b)
{
    if(b==0) return 1;
    if(b==1) return a%MOD;
    ll temp=POW(a,b/2);
    if(b%2==0) return (temp*temp)%MOD;
    else return (((temp*temp)%MOD)*a)%MOD;
}

int main()
{long long int n,a,b,k;
cin >>n>>a>>b>>k;
string s1;
cin >> s1;
if(a!=b)
{
long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=(POW(a,n-i)*POW(b,i))%MOD;
        sum=sum%MOD;
    }
else
{sum-=(POW(a,n-i)*POW(b,i))%MOD;
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int res,res1,res2,res3=(b*inverse(a))%MOD;
n++;
res=(POW(res3,n)-1)%MOD;
if(res<=0)
{res+=MOD;}
res1=(POW(res3,k)-1)%MOD;
if(res1<=0)
res1+=MOD;
long long int finres;
finres=((sum*res)%MOD*inverse(res1))%MOD;
cout<<finres<<"\n";}
else
{long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=POW(a,n);
        sum=sum%MOD;
    }
else
{sum-=POW(a,n);
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int finres=(((n+1)/k)%MOD*sum)%MOD;
    cout<<finres<<"\n";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define ld long double
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define F first
#define S second
const int MOD=1000000000+9;
long long int inverse(long long int i){
    if(i==1) return 1;
    return (MOD - ((MOD/i)*inverse(MOD%i))%MOD+MOD)%MOD;
}
ll POW(ll a,ll b)
{
    if(b==0) return 1;
    if(b==1) return a%MOD;
    ll temp=POW(a,b/2);
    if(b%2==0) return (temp*temp)%MOD;
    else return (((temp*temp)%MOD)*a)%MOD;
}

int main()
{long long int n,a,b,k;
cin >>n>>a>>b>>k;
string s1;
cin >> s1;
if(a!=b)
{
long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=(POW(a,k-i-1)*POW(b,i))%MOD;
        sum=sum%MOD;
    }
else
{sum-=(POW(a,k-i-1)*POW(b,i))%MOD;
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int res,res1,res2;
n++;
if(b>a)
{res=(POW(b,n)-POW(a,n))%MOD;
    if(res<0)
    res+=MOD;
    res1=(POW(b,k)-POW(a,k))%MOD;
    if(res1<0)
    res1+=MOD;

}
else
{res=(-POW(b,n)
+POW(a,n))%MOD;
    if(res<0)
    res+=MOD;
    res1=(-POW(b,k)+POW(a,k))%MOD;
    if(res1<0)
    res1+=MOD;

}
long long int finres;
finres=((sum*res)%MOD*inverse(res1))%MOD;
cout<<finres<<"\n";}
else
{long long int sum=0;
for(int i=0;i<s1.size();++i)
{if(s1[i]=='+')
    {sum+=POW(a,n-i);
        sum=sum%MOD;
    }
else
{sum-=POW(a,n-i);
        sum=sum%MOD;
        if(sum<0)
    sum+=MOD;
}}
long long int finres=((n+1)%MOD*sum)%MOD;
    cout<<finres<<"\n";
}

}


#include <iostream>

using namespace std;
typedef long long ll;

const int mod = int(1e9+9);
int n,a,b,k;
string s;
ll res;

ll mod_pow(ll x,ll n){

    ll res=1;
    while(n)
    {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
int main(){

    cin>>n>>a>>b>>k>>s;
    ll ac=mod_pow(a,n);
    ll q=mod_pow(b,k)*mod_pow(mod_pow(a,k),mod-2)%mod;
    for(int i = 0; i < k; i++)
    {
        (res+=(s[i]=='+' ? 1 : -1)*ac)%= mod;
        (ac*=(b*mod_pow(a,mod-2))%mod)%=mod;
    }
    if(q == 1)
    (res*=(n+1)/k)%=mod;
    else
    (res*=(1-mod_pow(q,(n+1)/k))*mod_pow(1-q,mod-2)%mod)%=mod;
    cout <<(res+mod)%mod<<endl;

//    system("pause");
    return 0;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod int(1e9+9)
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = power(x, y/2)%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    opt;
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ld tmpA = power(a, k), tmpB = power(b, k);
    ll ans = 0;
    ld temp = tmpA/tmpB;
    ld T = 0, t = 1;
    for(int i=0; i<n/k; i++)
    {
        T += t;
        t *= temp;
        ll tt  = t+EPS;
        t = (tt%mod) + (t - tt);
    }
    for(int i=0; i<k; i++)
    {

        ll co = (s[i]=='+')? 1 : -1;
        /*
        int cnt, fac1, fac2;
        cnt = n/k;
        fac1 = cnt*i;
        fac1 += (cnt*(cnt-1) / 2)*k;
        int tmp = (n-i-1);
        fac2 = tmp%k;

        fac2 +=
        */
        //ll tmp = pow(a, i) * pow(b, n-i-1);
        ld tmp = ((power(b, n-1-i)%mod) * (power(a, i)%mod))%mod * ld(T);
        ll tp = tmp + EPS;
        if(co == -1)
            co += mod;
        ll cnt = ((co) * (tp%mod))%mod;
        ans += cnt;
        ans %= mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod int(1e9+9)
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
//=================================
ld power(ld x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ld temp = power(x, y/2);
    temp = fmod(temp, mod);
    temp *= temp;
    temp = fmod(temp, mod);
    if(y%2 == 1)
        temp *= x;
    return fmod(temp, mod);
}
int main()
{
    opt;
    ll n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;

    for(int i=0; i<k; i++)
    {

        ll co = (s[i]=='+')? 1 : -1;
        /*
        int cnt, fac1, fac2;
        cnt = n/k;
        fac1 = cnt*i;
        fac1 += (cnt*(cnt-1) / 2)*k;
        int tmp = (n-i-1);
        fac2 = tmp%k;

        fac2 +=
        */
        //ll tmp = pow(a, i) * pow(b, n-i-1);
        ll tmp = (((ll)power(a, n-1-i)%mod) * ((ll)power(b, i)%mod))%mod ;
        ll cnt = ((co) * (tmp%mod))%mod;
        ans += cnt;
        ans %= mod;
    }
    //cout << ans << endl;
    ll ANS = 0;
    for(int i=0; i<n/k; i++)
    {
        ld tmp = power(ld(b)/ld(a), k*i);

        ANS += ans * tmp;
        while(ANS < 0)
            ANS += mod;
        ANS %= mod;
       //cout << tmp << endl;
    }
    cout << ANS << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod int(1e9+9)
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
//=================================
ld power(ld x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ld temp = power(x, y/2);
    temp = fmod(temp, mod);
    temp *= temp;
    temp = fmod(temp, mod);
    if(y%2 == 1)
        temp *= x;
    return fmod(temp, mod);
}
int main()
{
    opt;
    ll n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;

    for(int i=0; i<k; i++)
    {

        ll co = (s[i]=='+')? 1 : -1;
        /*
        int cnt, fac1, fac2;
        cnt = n/k;
        fac1 = cnt*i;
        fac1 += (cnt*(cnt-1) / 2)*k;
        int tmp = (n-i-1);
        fac2 = tmp%k;

        fac2 +=
        */
        //ll tmp = pow(a, i) * pow(b, n-i-1);
        ll tmp = (((ll)power(a, n-1-i)%mod) * ((ll)power(b, i)%mod))%mod ;
        if(co == -1)
            co += mod;
        ll cnt = ((co) * (tmp%mod))%mod;
        ans += cnt;
        ans %= mod;
    }
    //cout << ans << endl;
    ll ANS = 0;
    for(int i=0; i<n/k; i++)
    {
        ld tmp = power(ld(b)/ld(a), k*i);
        ANS += ans * tmp;
       //cout << tmp << endl;
        ANS %= mod;
    }
    cout << ANS << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod int(1e9+9)
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = power(x, y/2)%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    opt;
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ld tmpA = power(a, k), tmpB = power(b, k);
    ll ans = 0;
    ld temp = tmpB/tmpA;
    ld T = 0, t = 1;
     for(int i=0; i<n/k; i++)
    {
        T += t;
        T = ((ll)T % mod) + (T - (ll)T);
        t *= temp;
        ll tt  = t+EPS;
        t = (tt%mod) + (t - tt);
    }
    for(int i=0; i<k; i++)
    {

        ll co = (s[i]=='+')? 1 : -1;
        /*
        int cnt, fac1, fac2;
        cnt = n/k;
        fac1 = cnt*i;
        fac1 += (cnt*(cnt-1) / 2)*k;
        int tmp = (n-i-1);
        fac2 = tmp%k;

        fac2 +=
        */
        //ll tmp = pow(a, i) * pow(b, n-i-1);
        ld tmp = ((power(a, n-1-i)%mod) * (power(b, i)%mod))%mod * ld(T);
        ll tp = tmp + EPS;
        if(co == -1)
            co += mod;
        ll cnt = ((co) * (tp%mod))%mod;
        ans += cnt;
        ans %= mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
const ll mod = 1e9+9;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = (power(x, y/2))%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    opt;
    ll n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ll term = 0;
    for(int i=0; i<k; i++)
    {
        ll co = (s[i]=='+')? 1 : -1;
        term += co * power(a, k-1-i)%mod * power(b, i)%mod;
        term = (term+mod)%mod;
    }
    ll r = power(b, k) * power(power(a, k), mod-2);
    r %= mod;
    term = (term * (power(a, (n-k))));
    term %= mod;
    if(r == 1)
        ans = (term * (n/k))%mod;
    else
        ans = (term * (1 - power(r, (n/k)) + mod))%mod * power(1-r+mod, mod-2);
    ans %= mod;
    while(ans < 0)
        ans += mod;
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod int(1e9+9)
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = power(x, y/2)%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    opt;
    ll n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ll term = 0;
    for(int i=0; i<k; i++)
    {
        ll co = (s[i]=='+')? 1 : -1;
        if(co == -1)
            co += mod;
        term += co * (power(a, k-1-i) * power(b, i))%mod;
        term %= mod;
    }
    for(int i=0; i<n/k; i++)
    {
        ll co = (power(a, (n-k) - (i*k)) * power(b, i*k))%mod;
        //cout << co << endl;
        ans += term * co;
        ans %= mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod int(1e9+9)
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = power(x, y/2)%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    opt;
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ld tmpA = power(a, k), tmpB = power(b, k);
    ll ans = 0;
    ld temp = tmpA/tmpB;
    ld T = 0, t = 1;
    for(int i=0; i<n/k; i++)
        T += t, t *= temp, t%= mod;
    for(int i=0; i<k; i++)
    {

        ll co = (s[i]=='+')? 1 : -1;
        /*
        int cnt, fac1, fac2;
        cnt = n/k;
        fac1 = cnt*i;
        fac1 += (cnt*(cnt-1) / 2)*k;
        int tmp = (n-i-1);
        fac2 = tmp%k;

        fac2 +=
        */
        //ll tmp = pow(a, i) * pow(b, n-i-1);
        ld tmp = ((power(b, n-1-i)%mod) * (power(a, i)%mod))%mod * ld(T);
        ll tp = tmp + EPS;
        if(co == -1)
            co += mod;
        ll cnt = ((co) * (tp%mod))%mod;
        ans += cnt;
        ans %= mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
const ll mod = 1e9+9;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = (power(x, y/2))%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    opt;
    ll n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ll term = 0;
    for(int i=0; i<k; i++)
    {
        ll co = (s[i]=='+')? 1 : -1;
        term += fmod(co * fmod((power(a, k-1-i) * power(b, i)), mod), mod);
        //cout << (co * ((power(a, k-1-i) * power(b, i)))%mod)%mod << endl;
        term %= mod;
    }
    ll r = power(b, k) * power(power(a, k), mod-2);
    r %= mod;
    term = (term * (power(a, (n-k))));
    term %= mod;
    if(r == 1)
        ans = (term * (n/k))%mod;
    else
        ans = (((term * (1 - power(r, (n/k))))%mod * power(1-r+mod, mod-2)));
    ans %= mod;
    while(ans < 0)
        ans += mod;
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod int(1e9+9)
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = power(x, y/2)%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    opt;
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ld tmpA = power(a, k), tmpB = power(b, k);
    ll ans = 0;
    ld temp = tmpA/tmpB;
    ld T = 0, t = 1;
     for(int i=0; i<n/k; i++)
    {
        T += t;
        T = ((ll)T % mod) + (T - (ll)T);
        t *= temp;
        ll tt  = t+EPS;
        t = (tt%mod) + (t - tt);
    }
    for(int i=0; i<k; i++)
    {

        ll co = (s[i]=='+')? 1 : -1;
        /*
        int cnt, fac1, fac2;
        cnt = n/k;
        fac1 = cnt*i;
        fac1 += (cnt*(cnt-1) / 2)*k;
        int tmp = (n-i-1);
        fac2 = tmp%k;

        fac2 +=
        */
        //ll tmp = pow(a, i) * pow(b, n-i-1);
        ld tmp = ((power(b, n-1-i)%mod) * (power(a, i)%mod))%mod * ld(T);
        ll tp = tmp + EPS;
        if(co == -1)
            co += mod;
        ll cnt = ((co) * (tp%mod))%mod;
        ans += cnt;
        ans %= mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define EPS 0.000000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
const ll mod = 1e9+9;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = power(x, y/2)%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    opt;
    ll n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ll term = 0;
    for(int i=0; i<k; i++)
    {
        ll co = (s[i]=='+')? 1 : -1;
        if(co == -1)
            co += mod;
        term += (co * ((power(a, k-1-i) * power(b, i)))%mod)%mod;
        term %= mod;
    }
    for(int i=0; i<n/k; i++)
    {
        ll co = (power(a, (n-k) - (i*k)) * power(b, i*k))%mod;
        //cout << co << endl;
        ans += (term * co)%mod;
        ans %= mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define EPS 0.0000000001;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod int(1e9+9)
#define clr(i, j)   memset(i, j, sizeof i)
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef  long long ll;
typedef unsigned long long ull ;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
//=================================
ll power(ll x, ll y)
{
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    ll temp = power(x, y/2)%mod;
    temp *= temp;
    temp %= mod;
    if(y%2 == 1)
        temp *= x;
    return temp % mod;
}
int main()
{
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    n++;
    string s;
    cin >> s;
    ld tmpA = power(a, k), tmpB = power(b, k);
    ll ans = 0;
    ld temp = tmpB/tmpA;
    ld T = 0, t = 1;
    for(int i=0; i<n/k; i++)
        T += t, t *= temp;
    for(int i=0; i<k; i++)
    {

        ll co = (s[i]=='+')? 1 : -1;
        /*
        int cnt, fac1, fac2;
        cnt = n/k;
        fac1 = cnt*i;
        fac1 += (cnt*(cnt-1) / 2)*k;
        int tmp = (n-i-1);
        fac2 = tmp%k;

        fac2 +=
        */
        //ll tmp = pow(a, i) * pow(b, n-i-1);
        ld tmp = ((power(a, n-1-i)%mod) * (power(b, i)%mod))%mod * ld(T);
        ll tp = tmp + EPS;
        ll cnt = (co) * (tp%mod);
        if(cnt < 0)
            cnt += mod;
        ans += cnt;
        ans %= mod;
    }
    cout << ans << endl;
}