#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long, long long> M;
  string s;
  cin>>s;
  long long i,j,k,ans=0,n;
  n=s.length();
  long long b[n];
  for(i=0;i<s.length();i++)
  {
    b[i]=-1;
    if(s[i]=='a')
    {
      ans++;
    }
    ans=ans%(1000000007);
  }
  for(i=0;i<n;i++)
  {
    if(s[i]=='b')
    {
      b[i]=0;
    }
    else{
      b[i]=1;
    }
  }
  j=0;
  for(i=0;i<n;i++)
  {
    if(b[i]==0)
    {
      continue;
    }
    else{
      k=0;
      while(b[i]!=0 && i<n)
      {
        if(s[i]=='a'){
          ans+=j;
          k++;
        }
        ans=ans%(1000000007);
        i++;
      }
      j+=k;
    }
  }
  cout<<ans;
  return 0;
}

long long gcd(long long a,long long b)
{
  if(b==0)
    {
      return a;
    }
  else{
    return gcd(b,a%b);
  }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long, long long> M;
  string s;
  cin>>s;
  long long i,j,k,ans=0,n,cnt=1;
  n=s.length();
  long long b[n];
  for(i=0;i<s.length();i++)
  {
    b[i]=-1;
    if(s[i]=='a')
    {
      ans++;
    }
    ans=ans%(1000000007);
  }
  for(i=0;i<n;i++)
  {
    if(s[i]=='a' && s[i+1]=='b')
    {
      b[i]=cnt;
      cnt++;
    }
    else if(s[i]=='b')
    {
      b[i]=0;
    }
    else{
      b[i]=cnt;
    }
  }
  j=0;
  for(i=0;i<n;i++)
  {
    if(b[i]==0)
    {
      continue;
    }
    else{
      k=0;
      while(b[i]!=0 && i<n)
      {
        if(s[i]=='a'){
          ans+=j;
          k++;
        }
        ans=ans%(1000000007);
        i++;
      }
      j+=k;
    }
  }
  cout<<ans;
  return 0;
}

long long gcd(long long a,long long b)
{
  if(b==0)
    {
      return a;
    }
  else{
    return gcd(b,a%b);
  }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long, long long> M;
  string s;
  cin>>s;
  long long i,j,k,ans=0,n,cnt=1;
  n=s.length();
  long long b[n];
  for(i=0;i<s.length();i++)
  {
    b[i]=-1;
    if(s[i]=='a')
    {
      ans++;
    }
    ans=ans%(1000000007);
  }
  for(i=0;i<n;i++)
  {
    if(s[i]=='a' && s[i+1]=='b')
    {
      b[i]=cnt;
      cnt++;
    }
    else if(s[i]=='b')
    {
      b[i]=0;
    }
    else{
      b[i]=cnt;
    }
  }
  j=0;
  i=0;
  if(b[0]==1)
  {
    for(i=0;;i++)
    {
      if(b[i]!=1)
      {
        break;
      }
      else if(s[i]=='a'){
        j++;
      }
    }
  }
  for(i=i;i<n;i++)
  {
    if(b[i]==0)
    {
      continue;
    }
    else{
      k=0;
      while(b[i]!=0 && i<n)
      {
        if(s[i]=='a'){
          ans+=j;
          k++;
        }
        ans=ans%(1000000007);
        i++;
      }
      j+=k;
    }
  }
  cout<<ans;
  return 0;
}

long long gcd(long long a,long long b)
{
  if(b==0)
    {
      return a;
    }
  else{
    return gcd(b,a%b);
  }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long, long long> M;
  string s;
  cin>>s;
  long long i,j,k,ans=0,n,cnt=1;
  n=s.length();
  long long b[n];
  for(i=0;i<s.length();i++)
  {
    b[i]=-1;
    if(s[i]=='a')
    {
      ans++;
    }
    ans=ans%(1000000007);
  }
  for(i=0;i<n;i++)
  {
    if(s[i]=='a' && s[i+1]=='b')
    {
      b[i]=cnt;
      cnt++;
    }
    else if(s[i]=='b')
    {
      b[i]=0;
    }
    else{
      b[i]=cnt;
    }
  }
  j=0;
  i=0;
  if(b[0]==1)
  {
    for(i=0;;i++)
    {
      if(b[i]!=1)
      {
        break;
      }
      else{
        j++;
      }
    }
  }
  for(i=i;i<n;i++)
  {
    if(b[i]==0)
    {
      continue;
    }
    else{
      k=0;
      while(b[i]!=0 && i<n)
      {
        if(s[i]=='a'){
          ans+=j;
          k++;
        }
        ans=ans%(1000000007);
        i++;
      }
      j+=k;
    }
  }
  cout<<ans;
  return 0;
}

long long gcd(long long a,long long b)
{
  if(b==0)
    {
      return a;
    }
  else{
    return gcd(b,a%b);
  }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long, long long> M;
  string s;
  cin>>s;
  long long i,j,k,ans=0,n,cnt=1;
  n=s.length();
  long long b[n];
  for(i=0;i<s.length();i++)
  {
    b[i]=-1;
    if(s[i]=='a')
    {
      ans++;
    }
    ans=ans%(1000000007);
  }
  for(i=0;i<n;i++)
  {
    if(s[i]=='a' && s[i+1]=='b')
    {
      b[i]=cnt;
      cnt++;
    }
    else if(s[i]=='b')
    {
      b[i]=0;
    }
    else{
      b[i]=cnt;
    }
  }
  j=0;
  i=0;
  if(b[0]==1)
  {
    for(i=0;;i++)
    {
      if(b[i]!=1)
      {
        break;
      }
      else{
        j++;
      }
    }
  }
  for(i=i;i<n;i++)
  {
    if(b[i]==0)
    {
      continue;
    }
    else{
      k=0;
      while(b[i]!=0 && i<n)
      {
        ans+=j;
        k++;
        ans=ans%(1000000007);
        i++;
      }
      j+=k;
    }
  }
  cout<<ans;
  return 0;
}

long long gcd(long long a,long long b)
{
  if(b==0)
    {
      return a;
    }
  else{
    return gcd(b,a%b);
  }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long, long long> M;
  string s;
  cin>>s;
  long long i,j,k,ans=0,n,cnt=1;
  n=s.length();
  long long b[n];
  for(i=0;i<s.length();i++)
  {
    b[i]=-1;
    if(s[i]=='a')
    {
      ans++;
    }
    ans=ans%(1000000007);
  }
  for(i=0;i<n;i++)
  {
    if(s[i]=='a' && s[i+1]=='b')
    {
      b[i]=cnt;
      cnt++;
    }
    else if(s[i]=='b')
    {
      b[i]=0;
    }
    else if(s[i]=='a'){
      b[i]=cnt;
    }
  }
  j=0;
  i=0;
  if(b[0]==1)
  {
    for(i=0;;i++)
    {
      if(b[i]!=1)
      {
        break;
      }
      else{
        j++;
      }
    }
  }
  for(i=i;i<n;i++)
  {
    if(b[i]==0)
    {
      continue;
    }
    else{
      k=0;
      while(b[i]!=0 && i<n)
      {
        ans+=j;
        k++;
        ans=ans%(1000000007);
        i++;
      }
      j+=k;
    }
  }
  cout<<ans;
  return 0;
}

long long gcd(long long a,long long b)
{
  if(b==0)
    {
      return a;
    }
  else{
    return gcd(b,a%b);
  }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long, long long> M;
  string s;
  cin>>s;
  long long i,j,k,ans=0,n;
  n=s.length();
  long long b[n];
  for(i=0;i<s.length();i++)
  {
    b[i]=-1;
  }
  for(i=0;i<n;i++)
  {
    if(s[i]=='b')
    {
      b[i]=0;
    }
    else{
      b[i]=1;
    }
  }
  j=0;
  for(i=0;i<n;i++)
  {
    if(b[i]==0)
    {
      continue;
    }
    else{
      k=0;
      while(b[i]!=0 && i<n)
      {
        if(s[i]=='a'){
          k++;
        }
        i++;
      }
      ans+=ans*k;
      ans+=k;
      ans=ans%(1000000007);
    }
  }
  cout<<ans;
  return 0;
}

long long gcd(long long a,long long b)
{
  if(b==0)
    {
      return a;
    }
  else{
    return gcd(b,a%b);
  }
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(ll i = (x); i <= (y); ++i)
#define bug1(a) cout << #a << " = " << a << endl;
#define bug2(a,b) cout << #a << " = " << a <<", "<< #b << " = " << b<< endl;
#define bug3(a,b,c) cout << #a << " = " << a <<", "<< #b << " = " << b<<", "<< #c << " = " << c<< endl;
#define fbug(a, x, y) { cout << #a << ": "; rep(i, x, y) cout << a[i] << ' '; cout << endl; }
#define pb push_back
//#define mp make_pair
#define endd "\n"
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input freopen("inp.txt","r",stdin)
#define output freopen("out2.txt","w",stdout)
#define loop(i,n) for(ll i=0;i<n;i++)
#define rloop(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long
#define Z size()
#define pii pair<int,int>
#define setp(x) fixed<<setprecision(x)
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pi 3.14159265358979323846264338327950288419716939937510
#define mset(x) memset(x,-1,sizeof x);
#define spa cout<<endd
#define com(x)#x
//#define modexp
#define rcd(x) cout<<"Reached at: "<<x<<endd
#ifdef modexp
ll power(ll a , ll b,ll modi){
    ll res = 1 ;
    while(b){
        if(b & 1) res = (res * a) % modi ;
        b /= 2 ;
        a = (a * a) % modi ;
    }
    return res ;
}
#endif
int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
//*******************************TEMPLATE ENDS HERE *******************//
string s;
const int mod = 1e9 + 7;
vector<int>ida, idb;
ll dp[100002][2];
ll rec(int idx, bool v){
    if(idx >= ida.Z)return 0;
    ll &ans  = dp[idx][v];
    if(~ans) return ans;
    ans = 0;
   // bug3(ida[idx], idx, v);

    rep(i, idx + 1, ida.Z){
        int pos = upper_bound(all(idb), ida[idx]) - idb.begin();
        if(pos >= idb.Z)continue;
       // bug3(ida[idx], ida[i], idb[pos]);
        if(ida[idx] < idb[pos] && ida[i] > idb[pos]){
            ans += rec(i, 0) + 1;
        }

    }

    if(v)
     ans += rec(idx + 1, 1) + 1;

    return ans;

}
int main(){
  //  input;
    mset(dp);
    cin >> s;
    loop(i, s.Z){
        if(s[i] == 'a')ida.pb(i);
        if(s[i] == 'b')idb.pb(i);
    }
   // bug2(ida.Z, idb.Z);
    cout<<rec(0, 1);

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(ll i = (x); i <= (y); ++i)
#define bug1(a) cout << #a << " = " << a << endl;
#define bug2(a,b) cout << #a << " = " << a <<", "<< #b << " = " << b<< endl;
#define bug3(a,b,c) cout << #a << " = " << a <<", "<< #b << " = " << b<<", "<< #c << " = " << c<< endl;
#define fbug(a, x, y) { cout << #a << ": "; rep(i, x, y) cout << a[i] << ' '; cout << endl; }
#define pb push_back
//#define mp make_pair
#define endd "\n"
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input freopen("inp.txt","r",stdin)
#define output freopen("out2.txt","w",stdout)
#define loop(i,n) for(ll i=0;i<n;i++)
#define rloop(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long
#define Z size()
#define pii pair<int,int>
#define setp(x) fixed<<setprecision(x)
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pi 3.14159265358979323846264338327950288419716939937510
#define mset(x) memset(x,-1,sizeof x);
#define spa cout<<endd
#define com(x)#x
//#define modexp
#define rcd(x) cout<<"Reached at: "<<x<<endd
#ifdef modexp
ll power(ll a , ll b,ll modi){
    ll res = 1 ;
    while(b){
        if(b & 1) res = (res * a) % modi ;
        b /= 2 ;
        a = (a * a) % modi ;
    }
    return res ;
}
#endif
int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
//*******************************TEMPLATE ENDS HERE *******************//
string s;
const int mod = 1e9 + 7;
vector<int>ida, idb;
ll dp[100002][2];
ll rec(int idx, bool v){
    if(idx >= ida.Z)return 0;
    ll &ans  = dp[idx][v];
    if(~ans) return ans;
    ans = 0;
   // bug3(ida[idx], idx, v);

    rep(i, idx + 1, ida.Z){
        int pos = upper_bound(all(idb), ida[idx]) - idb.begin();
        if(pos >= idb.Z)continue;
       // bug3(ida[idx], ida[i], idb[pos]);
        if(ida[idx] < idb[pos] && ida[i] > idb[pos]){
            ans += rec(i, 0) + 1;
            ans %= mod;
        }

    }

    if(v){
     ans += rec(idx + 1, 1) + 1;
     ans %= mod;
    }

    return ans;

}
int main(){
    //input;
    mset(dp);
    cin >> s;
    loop(i, s.Z){
        if(s[i] == 'a')ida.pb(i);
        if(s[i] == 'b')idb.pb(i);
    }
   // bug2(ida.Z, idb.Z);
    cout<<rec(0, 1);

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(ll i = (x); i <= (y); ++i)
#define bug1(a) cout << #a << " = " << a << endl;
#define bug2(a,b) cout << #a << " = " << a <<", "<< #b << " = " << b<< endl;
#define bug3(a,b,c) cout << #a << " = " << a <<", "<< #b << " = " << b<<", "<< #c << " = " << c<< endl;
#define fbug(a, x, y) { cout << #a << ": "; rep(i, x, y) cout << a[i] << ' '; cout << endl; }
#define pb push_back
//#define mp make_pair
#define endd "\n"
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input freopen("inp.txt","r",stdin)
#define output freopen("out2.txt","w",stdout)
#define loop(i,n) for(ll i=0;i<n;i++)
#define rloop(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long
#define Z size()
#define pii pair<int,int>
#define setp(x) fixed<<setprecision(x)
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pi 3.14159265358979323846264338327950288419716939937510
#define mset(x) memset(x,-1,sizeof x);
#define spa cout<<endd
#define com(x)#x
//#define modexp
#define rcd(x) cout<<"Reached at: "<<x<<endd
#ifdef modexp
ll power(ll a , ll b,ll modi){
    ll res = 1 ;
    while(b){
        if(b & 1) res = (res * a) % modi ;
        b /= 2 ;
        a = (a * a) % modi ;
    }
    return res ;
}
#endif
int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
//*******************************TEMPLATE ENDS HERE *******************//
string s;
const int mod = 1e9 + 7;

int main(){
   // input;
    ll cnt = 1 , res = 1;
    cin >> s;
    loop(i, s.Z){
        if(s[i] == 'a')cnt++;
        if(s[i] == 'b')res = (res * cnt) % mod, cnt = 1;
    }
    res *= cnt;
    res %= mod;
   // bug2(ida.Z, idb.Z);
    res--;
    if(res < 0) res += mod;
    cout<<res;

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(ll i = (x); i <= (y); ++i)
#define bug1(a) cout << #a << " = " << a << endl;
#define bug2(a,b) cout << #a << " = " << a <<", "<< #b << " = " << b<< endl;
#define bug3(a,b,c) cout << #a << " = " << a <<", "<< #b << " = " << b<<", "<< #c << " = " << c<< endl;
#define fbug(a, x, y) { cout << #a << ": "; rep(i, x, y) cout << a[i] << ' '; cout << endl; }
#define pb push_back
//#define mp make_pair
#define endd "\n"
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input freopen("inp.txt","r",stdin)
#define output freopen("out2.txt","w",stdout)
#define loop(i,n) for(ll i=0;i<n;i++)
#define rloop(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long
#define Z size()
#define pii pair<int,int>
#define setp(x) fixed<<setprecision(x)
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pi 3.14159265358979323846264338327950288419716939937510
#define mset(x) memset(x,-1,sizeof x);
#define spa cout<<endd
#define com(x)#x
//#define modexp
#define rcd(x) cout<<"Reached at: "<<x<<endd
#ifdef modexp
ll power(ll a , ll b,ll modi){
    ll res = 1 ;
    while(b){
        if(b & 1) res = (res * a) % modi ;
        b /= 2 ;
        a = (a * a) % modi ;
    }
    return res ;
}
#endif
int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
//*******************************TEMPLATE ENDS HERE *******************//
string s;
const int mod = 1e9 + 7;

int main(){
   // input;
    ll cnt = 1 , res = 1;
    cin >> s;
    loop(i, s.Z){
        if(s[i] == 'a')cnt++;
        if(s[i] == 'b')res = (res * cnt) % mod, cnt = 1;
    }
   // bug2(ida.Z, idb.Z);
    res--;
    if(res < mod) res += mod;
    cout<<res;

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(ll i = (x); i <= (y); ++i)
#define bug1(a) cout << #a << " = " << a << endl;
#define bug2(a,b) cout << #a << " = " << a <<", "<< #b << " = " << b<< endl;
#define bug3(a,b,c) cout << #a << " = " << a <<", "<< #b << " = " << b<<", "<< #c << " = " << c<< endl;
#define fbug(a, x, y) { cout << #a << ": "; rep(i, x, y) cout << a[i] << ' '; cout << endl; }
#define pb push_back
//#define mp make_pair
#define endd "\n"
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input freopen("inp.txt","r",stdin)
#define output freopen("out2.txt","w",stdout)
#define loop(i,n) for(ll i=0;i<n;i++)
#define rloop(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long
#define Z size()
#define pii pair<int,int>
#define setp(x) fixed<<setprecision(x)
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pi 3.14159265358979323846264338327950288419716939937510
#define mset(x) memset(x,-1,sizeof x);
#define spa cout<<endd
#define com(x)#x
//#define modexp
#define rcd(x) cout<<"Reached at: "<<x<<endd
#ifdef modexp
ll power(ll a , ll b,ll modi){
    ll res = 1 ;
    while(b){
        if(b & 1) res = (res * a) % modi ;
        b /= 2 ;
        a = (a * a) % modi ;
    }
    return res ;
}
#endif
int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
//*******************************TEMPLATE ENDS HERE *******************//
string s;
const int mod = 1e9 + 7;

int main(){
    input;
    ll cnt = 1 , res = 1;
    cin >> s;
    loop(i, s.Z){
        if(s[i] == 'a')cnt++;
        if(s[i] == 'b')res = (res * cnt) % mod, cnt = 1;
    }
    res *= cnt;
    res %= mod;
   // bug2(ida.Z, idb.Z);
    res--;
    if(res < 0) res += mod;
    cout<<res;

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(ll i = (x); i <= (y); ++i)
#define bug1(a) cout << #a << " = " << a << endl;
#define bug2(a,b) cout << #a << " = " << a <<", "<< #b << " = " << b<< endl;
#define bug3(a,b,c) cout << #a << " = " << a <<", "<< #b << " = " << b<<", "<< #c << " = " << c<< endl;
#define fbug(a, x, y) { cout << #a << ": "; rep(i, x, y) cout << a[i] << ' '; cout << endl; }
#define pb push_back
//#define mp make_pair
#define endd "\n"
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input freopen("inp.txt","r",stdin)
#define output freopen("out2.txt","w",stdout)
#define loop(i,n) for(ll i=0;i<n;i++)
#define rloop(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long
#define Z size()
#define pii pair<int,int>
#define setp(x) fixed<<setprecision(x)
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pi 3.14159265358979323846264338327950288419716939937510
#define mset(x) memset(x,-1,sizeof x);
#define spa cout<<endd
#define com(x)#x
//#define modexp
#define rcd(x) cout<<"Reached at: "<<x<<endd
#ifdef modexp
ll power(ll a , ll b,ll modi){
    ll res = 1 ;
    while(b){
        if(b & 1) res = (res * a) % modi ;
        b /= 2 ;
        a = (a * a) % modi ;
    }
    return res ;
}
#endif
int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
//*******************************TEMPLATE ENDS HERE *******************//
string s;
const int mod = 1e9 + 7;
vector<int>ida, idb;
ll dp[100002][3];
ll rec(int idx, bool v){
    if(idx >= ida.Z)return 0;
    ll &ans  = dp[idx][v];
   // if(~ans) return ans;
    ans = 0;
   // bug3(ida[idx], idx, v);

    rep(i, idx + 1, ida.Z){
        int pos = upper_bound(all(idb), ida[idx]) - idb.begin();
        if(pos >= idb.Z)continue;
       // bug3(ida[idx], ida[i], idb[pos]);
        if(ida[idx] < idb[pos] && ida[i] > idb[pos]){
            ans += rec(i, 0) + 1;
            ans %= mod;
        }

    }

    if(v){
     ans += rec(idx + 1, 1) + 1;
     ans %= mod;
    }

    return ans;

}
int main(){
   // input;
    mset(dp);
    cin >> s;
    loop(i, s.Z){
        if(s[i] == 'a')ida.pb(i);
        if(s[i] == 'b')idb.pb(i);
    }
   // bug2(ida.Z, idb.Z);
    cout<<rec(0, 1);

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(ll i = (x); i <= (y); ++i)
#define bug1(a) cout << #a << " = " << a << endl;
#define bug2(a,b) cout << #a << " = " << a <<", "<< #b << " = " << b<< endl;
#define bug3(a,b,c) cout << #a << " = " << a <<", "<< #b << " = " << b<<", "<< #c << " = " << c<< endl;
#define fbug(a, x, y) { cout << #a << ": "; rep(i, x, y) cout << a[i] << ' '; cout << endl; }
#define pb push_back
//#define mp make_pair
#define endd "\n"
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input freopen("inp.txt","r",stdin)
#define output freopen("out2.txt","w",stdout)
#define loop(i,n) for(ll i=0;i<n;i++)
#define rloop(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long
#define Z size()
#define pii pair<int,int>
#define setp(x) fixed<<setprecision(x)
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pi 3.14159265358979323846264338327950288419716939937510
#define mset(x) memset(x,-1,sizeof x);
#define spa cout<<endd
#define com(x)#x
//#define modexp
#define rcd(x) cout<<"Reached at: "<<x<<endd
#ifdef modexp
ll power(ll a , ll b,ll modi){
    ll res = 1 ;
    while(b){
        if(b & 1) res = (res * a) % modi ;
        b /= 2 ;
        a = (a * a) % modi ;
    }
    return res ;
}
#endif
int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
//*******************************TEMPLATE ENDS HERE *******************//
string s;
const int mod = 1e9 + 7;

int main(){
   // input;
    ll cnt = 1 , res = 1;
    cin >> s;
    loop(i, s.Z){
        if(s[i] == 'a')cnt++;
        if(s[i] == 'b')res = (res * cnt) % mod, cnt = 1;
    }
   // bug2(ida.Z, idb.Z);
    res--;
    if(res < 0) res += mod;
    cout<<res;

}


#include<bits/stdc++.h>

using namespace std;
string s;
long long int dp[200000];
long long int d(long long int i)
{
    if(i<0)
        return 0;
    if(dp[i]==-1)
    {
        if(i==1)
            dp[i]=1;
        else if(s[i-1]=='a'&&s[i]=='a')
            dp[i]=2*d(i-1)-d(i-2);
        else if(s[i]=='a'&&s[i-1]=='b')
            dp[i]=2*d(i-1)+1;
        else if(s[i]=='a')
            dp[i]=d(i-1)+1;
        else
            dp[i]=d(i-1);
    }
    return dp[i];
}
int main() {
    cin>>s;
    for(long int i=0;i<200000;i++)
        dp[i]=-1;
    cout<<d(s.length()-1);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;

string s;
long long int dp[200000],t=0;
long long int d(long long int j)
{
    for(long long int i=0;i<=j;i++)
    {
        if(i==0&&s[i]=='a')
            dp[i]=1;
        else if(i==0)
            dp[i]=0;
        else if(s[i-1]=='a'&&s[i]=='a')
        {
            if(i==1)
               dp[i]=2*dp[i-1];
            else
               dp[i]=2*dp[i-1]-dp[i-2];
        }
        else if(s[i]=='a'&&(s[i-1]=='b'||t==1))
        {
            dp[i]=2*dp[i-1]+1;
            t=0;
        }
        else if(s[i]=='a')
            dp[i]=dp[i-1]+1;
        else
        {
            dp[i]=dp[i-1];
            if(s[i]=='b')
                t=1;
        }
    }
    return dp[j];
}
int main() {
    cin>>s;
   // cout<<s.length();
    cout<<d(s.length()-1);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;
string s;
long long int dp[200000];
long long int d(long long int i)
{
    if(i<0)
        return 0;
    if(dp[i]==-1)
    {
        if(i==0)
            dp[i]=1;
        else if(s[i-1]=='a'&&s[i]=='a')
            dp[i]=2*d(i-1)-d(i-2);
        else if(s[i]=='a'&&s[i-1]=='b')
            dp[i]=2*d(i-1)+1;
        else if(s[i]=='a')
            dp[i]=d(i-1)+1;
        else
            dp[i]=d(i-1);
    }
    return dp[i];
}
int main() {
    cin>>s;
    for(long int i=0;i<200000;i++)
        dp[i]=-1;
  //  cout<<s.length();
    cout<<d(s.length()-1);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;
string s;
long long int dp[200000];
long long int d(long long int i)
{
    if(i<0)
        return 0;
    if(dp[i]==-1)
    {
        if(i==0)
            dp[i]=1;
        else if(s[i-1]=='a'&&s[i]=='a')
            dp[i]=2*d(i-1)-d(i-2);
        else if(s[i]=='a'&&s[i-1]=='b')
            dp[i]=2*d(i-1)+1;
        else if(s[i]=='a')
            dp[i]=d(i-1)+1;
        else
            dp[i]=d(i-1);
    }
    return dp[i];
}
int main() {
    cin>>s;
    for(long int i=0;i<200000;i++)
        dp[i]=-1;
    cout<<s.length();
    cout<<d(s.length()-1);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;

string c;
char s[200000];
long long int dp[200000],t=0;
long long int d(long long int j)
{
    for(long long int i=0;i<=j;i++)
    {
        if(i==0&&s[i]=='a')
            dp[i]=1;
        else if(i==0)
            dp[i]=0;
        else if(s[i]!='a')
        {
            dp[i]=(dp[i-1]);
            if(s[i]=='b')
                t=1;
        }
        else if(s[i]='a')
        {
            if(t==1)
            {
                dp[i]=(2*dp[i-1]+1);
                t=0;
            }

            else
            {
               if(i==1)
                 dp[i]=(2*dp[i-1]);
               else
                 dp[i]=(2*dp[i-1]-dp[i-2]);
            }
        }
        dp[i]%=1000000007;
    }
    return dp[j];
}
int main() {

    cin>>c;
    long long int n=0;
    for(int i=0;i<c.length();i++)
    {
        if(c[i]=='a'||c[i]=='b')
        {
            s[n]=c[i];
            n++;
        }
    }
   // cout<<s.length();
    cout<<d(n);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;

string c;
char s[200000];
long long int dp[200000],t=0;
long long int d(long long int j)
{
    for(long long int i=0;i<=j;i++)
    {
        if(i==0&&s[i]=='a')
            dp[i]=1;
        else if(i==0)
            dp[i]=0;
        else if(s[i]!='a')
        {
            dp[i]=(dp[i-1]);
            if(s[i]=='b')
                t=1;
        }
        else if(s[i]='a')
        {
            if(t==1||s[i-1]=='b')
            {
                dp[i]=(2*dp[i-1]+1);
                t=0;
            }

            else
            {
               if(i==1)
                 dp[i]=(2*dp[i-1]);
               else
                 dp[i]=(2*dp[i-1]-dp[i-2]);
            }
        }
        dp[i]%=1000000007;
        if(dp[i]<0)
            dp[i]+=1000000007;
    }
    return dp[j];
}
int main() {

    cin>>c;
    long long int n=0;
    for(int i=0;i<c.length();i++)
    {
        if(c[i]=='a'||c[i]=='b')
        {
            s[n]=c[i];
            n++;
        }
    }
   // cout<<s.length();
    cout<<d(n);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;
string k;
char s[200000];
long long int dp[200000];
long long int d(long long int i)
{
    if(i<0)
        return 0;
    if(dp[i]==-1)
    {
        if(i==0&&s[i]=='a')
            dp[i]=1;
        else if(i==0)
            dp[i]=0;
        else if(s[i-1]=='a'&&s[i]=='a')
            dp[i]=2*d(i-1)-d(i-2);
        else if(s[i]=='a'&&s[i-1]=='b')
            dp[i]=2*d(i-1)+1;
        else if(s[i]=='a')
            dp[i]=d(i-1)+1;
        else
            dp[i]=d(i-1);
    }
    return dp[i];
}
int main() {
    cin>>k;
    for(long int i=0;i<200000;i++)
        dp[i]=-1;
    long long int i=0,n=0;
    while(i!=k.length())
    {
        if(k[i]=='a'||k[i]=='b')
        {
            s[n]=k[i];
            n++;
        }
        i++;
    }
   // cout<<s.length();
    cout<<d(n);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;

string s;
long long int dp[200000],t=0;
long long int d(long long int j)
{
    for(long long int i=0;i<=j;i++)
    {
        if(i==0&&s[i]=='a')
            dp[i]=1;
        else if(i==0)
            dp[i]=0;
        else if(s[i]!='a')
        {
            dp[i]=(dp[i-1]);
            if(s[i]=='b')
                t=1;
        }
        else if(s[i]='a')
        {
            if(t==1)
            {
                dp[i]=(2*dp[i-1]+1);
                t=0;
            }
            else if(s[i-1]!='a')
                dp[i]=(dp[i-1]+1);
            else
            {
               if(i==1)
                 dp[i]=(2*dp[i-1]);
               else
                 dp[i]=(2*dp[i-1]-dp[i-2]);
            }
        }
        dp[i]%=1000000007;
    }
    return dp[j];
}
int main() {
    cin>>s;
   // cout<<s.length();
    cout<<d(s.length()-1);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;
string s;
long long int dp[200000];
long long int d(long long int i)
{
    if(i<0)
        return 0;
    if(dp[i]==-1)
    {
        if(i==0&&s[i]=='a')
            dp[i]=1;
        else if(i==0)
            dp[i]=0;
        else if(s[i-1]=='a'&&s[i]=='a')
            dp[i]=2*d(i-1)-d(i-2);
        else if(s[i]=='a'&&s[i-1]=='b')
            dp[i]=2*d(i-1)+1;
        else if(s[i]=='a')
            dp[i]=d(i-1)+1;
        else
            dp[i]=d(i-1);
    }
    return dp[i];
}
int main() {
    cin>>s;
    for(long int i=0;i<200000;i++)
        dp[i]=-1;
   // cout<<s.length();
    cout<<d(s.length()-1);
    return 0;
 }


#include<bits/stdc++.h>

#include <cmath>
using namespace std;

string c;
char s[200000];
long long int dp[200000],t=0;
long long int d(long long int j)
{
    for(long long int i=0;i<=j;i++)
    {
        if(i==0&&s[i]=='a')
            dp[i]=1;
        else if(i==0)
            dp[i]=0;
        else if(s[i]!='a')
        {
            dp[i]=(dp[i-1]);
            if(s[i]=='b')
                t=1;
        }
        else if(s[i]='a')
        {
            if(t==1||s[i-1]=='b')
            {
                dp[i]=(2*dp[i-1]+1);
                t=0;
            }

            else
            {
               if(i==1)
                 dp[i]=(2*dp[i-1]);
               else
                 dp[i]=(2*dp[i-1]-dp[i-2]);
            }
        }
        dp[i]%=1000000007;
    }
    return dp[j];
}
int main() {

    cin>>c;
    long long int n=0;
    for(int i=0;i<c.length();i++)
    {
        if(c[i]=='a'||c[i]=='b')
        {
            s[n]=c[i];
            n++;
        }
    }
   // cout<<s.length();
    cout<<d(n);
    return 0;
 }


/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int main(){
   DHOKHA;
   string s;
   cin>>s;
   ll n=s.length();
   ll max1=0;
   ll count1=0;
   ll ans=0;
   ll i;
   ll mod=1e9+7;
   for(i=0;i<=n;i++){
   	 if(s[i]=='b'){
   	 	max1=count1;
   	 }
   	 if(s[i]!='a' && s[i]!='b'){
   	 	count1=0;
   	 	max1=0;
   	 }
   	 if(s[i]=='a'){
   	 	count1+=1;
   	 	ans=((ans%mod)+(max1%mod))%mod;
   	 	ans=((ans%mod)+(1LL%mod))%mod;
   	 }
   }
   cout<<ans;
}


/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll mod=1e9+7;
int main(){
   DHOKHA;

   string s;
   cin>>s;
   ll n=s.length();
   ll max1=0;
   ll count1=0;
   ll ans=0;
   ll i;
   ll ans1=1;
   ll ans2=0;
   for(i=0;i<=n;i++){
   	 if(s[i]=='b' && count1!=0){
   	 	ans1=((ans1%mod)*(count1%mod))%mod;
   	 	ans2=ans1;
   	 }
   	 if(s[i]=='a'){
   	 	count1+=1;
   	 	ans=((ans%mod)+(ans2%mod))%mod;
   	 	ans=((ans%mod)+(1LL%mod))%mod;
   	 }
   }
   cout<<ans;
}


/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll p[100005];
ll mod=1e9+7;
ll precompute(){
	p[0]=0;
	ll x=1;
	for(ll i=1;i<=100004;i++){
		x=(x%mod)*(2%mod);
		ll p1=(x+mod-1)%mod;
		p[i]=p1;
	}

}
int main(){
   DHOKHA;
   precompute();
   string s;
   cin>>s;
   ll n=s.length();
   ll max1=0;
   ll count1=0;
   ll ans=0;
   ll i;
   for(i=0;i<=n;i++){
   	 if(s[i]=='b'){
   	 	max1=count1;
   	 }
   	 if(s[i]=='a'){
   	 	count1+=1;
   	 	ans=((ans%mod)+(p[max1]%mod))%mod;
   	 	ans=((ans%mod)+(1LL%mod))%mod;
   	 }
   }
   cout<<ans;
}


/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll p[100005];
ll mod=1e9+7;
ll precompute(){
	p[0]=0;
	ll x=1;
	for(ll i=1;i<=100004;i++){
		x=((x%mod)*(2%mod))%mod;
		ll p1=(x+mod-1)%mod;
		p[i]=p1;
	}

}
int main(){
   DHOKHA;
   precompute();
   string s;
   cin>>s;
   ll n=s.length();
   ll max1=0;
   ll count1=0;
   ll ans=0;
   ll i;
   for(i=0;i<=n;i++){
   	 if(s[i]=='b'){
   	 	max1=count1;
   	 }
   	 if(s[i]=='a'){
   	 	count1+=1;
   	 	ans=((ans%mod)+(p[max1]%mod))%mod;
   	 	ans=((ans%mod)+(1LL%mod))%mod;
   	 }
   }
   cout<<ans;
}


/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll mod=1e9+7;
int main(){
   DHOKHA;

   string s;
   cin>>s;
   ll n=s.length();
   ll max1=0;
   ll count1=0;
   ll ans=0;
   ll i;
   ll ans1=0;
   ll ans2=0;
   for(i=0;i<=n;i++){
   	 if(s[i]=='b' && count1!=0){
   	 	ans1+=((ans1%mod)*(count1%mod))%mod;
   	 	ans1=(ans1%mod+count1%mod)%mod;
   	 	ans2=ans1;
   	 	count1=0;
   	 }
   	 if(s[i]=='a'){
   	 	count1+=1;
   	 	ans=((ans%mod)+(ans2%mod))%mod;
   	 	ans=((ans%mod)+(1LL%mod))%mod;
   	 }
   }
   cout<<ans;
}


/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll mod=1e9+7;
int main(){
   DHOKHA;

   string s;
   cin>>s;
   ll n=s.length();
   ll max1=0;
   ll count1=0;
   ll ans=0;
   ll i;
   ll ans1=1;
   ll ans2=0;
   for(i=0;i<=n;i++){
   	 if(s[i]=='b' && count1!=0){
   	 	ans1=((ans1%mod)*(count1%mod))%mod;
   	 	ans2=ans1;
   	 	count1=0;
   	 }
   	 if(s[i]=='a'){
   	 	count1+=1;
   	 	ans=((ans%mod)+(ans2%mod))%mod;
   	 	ans=((ans%mod)+(1LL%mod))%mod;
   	 }
   }
   cout<<ans;
}


/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll p[100005];
ll mod=1e9+7;
ll precompute(){
	p[0]=1;
	for(ll i=1;i<=100004;i++){
		p[i]=((p[i-1]%mod)*(2LL%mod))%mod;
	}
}
int main(){
   DHOKHA;
   precompute();
   string s;
   cin>>s;
   ll n=s.length();
   ll max1=0;
   ll count1=0;
   ll ans=0;
   ll i;
   for(i=0;i<=n;i++){
   	 if(s[i]=='b'){
   	 	max1=count1;
   	 }
   	 if(s[i]=='a'){
   	 	count1+=1;
   	 	ans=((ans%mod)+(p[max1]%mod))%mod;
   	 }
   }
   cout<<ans;
}


/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int main(){
   DHOKHA;
   string s;
   cin>>s;
   ll n=s.length();
   ll max1=0;
   ll count1=0;
   ll ans=0;
   ll i;
   ll mod=1e9+7;
   for(i=0;i<=n;i++){
   	 if(s[i]=='b'){
   	 	max1=count1;
   	 }
   	 if(s[i]=='a'){
   	 	count1+=1;
   	 	ans=((ans%mod)+(max1%mod))%mod;
   	 	ans=((ans%mod)+(1LL%mod))%mod;
   	 }
   }
   cout<<ans;
}


#include<iostream>
#include<string>
using namespace std;
int arr[100005];
int main()
{
    string str;
    cin>>str;
    unsigned long long int i,j,t;
    unsigned long long int count=0,count1=0,val=0;
    for(i=0;i<str.length();i++)
    {
        if(str[i]=='a')
        {
            count+=1;
            count1=0;
        }
        else if(str[i]=='b'&&count!=0&&count1==0)
        {
            arr[count-1]=1;
            count1==1;
        }
    }
   for(i=0;i<count;i++)
   {
       if(arr[i]==1)
       {
           val+=(count-i)%(1000000007);
       }
       else
       {
           val+=1;
       }
   }
   cout<<val;
}


#include<iostream>
#include<string>
using namespace std;
int arr[100005];
int main()
{
    string str;
    cin>>str;
    unsigned long long int i,j,t;
    unsigned long long int count=1,count1=0,val=0,sum=0;
    for(i=0;i<str.length();i++)
    {
        if(str[i]=='a')
        {
            val+=(1+sum);
        }
        else if(str[i]=='b')
        {
            sum=val;
        }
    }
   cout<<val%(1000000007);
}


#include<iostream>
#include<string>
using namespace std;
int arr[100005];
int main()
{
    string str;
    cin>>str;
    unsigned long long int i,j,t;
    unsigned long long int count=1,count1=0,val=0,sum=0;
    for(i=0;i<str.length();i++)
    {
        if(str[i]=='a')
        {
            val+=(1+sum)%(1000000007);
        }
        else if(str[i]=='b')
        {
            sum=val;
        }
    }
   cout<<val;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    cin>>str;
    unsigned long long int i,j,t;
    unsigned long long int count=1,count1=0,val=0,sum=0;
    for(i=0;i<str.length();i++)
    {
        if(str[i]=='a')
        {
            val+=(1+sum);
            count1=val%(1000000007);
        }
        else if(str[i]=='b')
        {
            sum=count1;
        }
    }
   cout<<count1;
}


#include<iostream>
#include<string>
using namespace std;
int arr[100005];
int main()
{
    string str;
    cin>>str;
    unsigned long long int i,j,t;
    unsigned long long int count=1,count1=0,val=0,sum=0;
    for(i=0;i<str.length();i++)
    {
        if(str[i]=='a')
        {
            val+=(1+sum)%(1000000007);
        }
        else if(str[i]=='b')
        {
            sum=val%(1000000007);
        }
    }
   cout<<val;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    cin>>str;
    unsigned long long int i,j,t;
    unsigned long long int count=1,count1=0,val=0,sum=0;
    for(i=0;i<str.length();i++)
    {
        if(str[i]=='a')
        {
            val+=(1+sum);
            count1=val%(1000000007);
        }
        else if(str[i]=='b')
        {
            sum=val;
        }
    }
   cout<<count1;
}


#include<iostream>
#include<string>
using namespace std;
int arr[100005];
int main()
{
    string str;
    cin>>str;
    unsigned long long int i,j,t;
    unsigned long long int count=0,count1=0,val=0,mark=1;
    for(i=(str.length()-1);i>=0;i--)
    {
        //cout<<i<<endl;
        if(str[i]=='a')
        {
            if(count1!=0&&mark==1)
            {
               arr[count]=mark+1;
               count+=1;
               count1=0;
            }
        arr[count]=mark;
        count+=1;
        count1=0;
        }
        else if(str[i]=='b'&&count1==0&&count!=0)
        {
            mark=count;
            count1=1;
        }
        if(i==0)
            break;
    }

   for(i=0;i<count;i++)
   {
       if(arr[i]==1){
       val+=arr[i]%(1000000007);}
       else
       {
           val+=1+arr[i]%(1000000007);
       }
   }
   cout<<val;
}


#include<iostream>
#include<string>
using namespace std;
int arr[100005];
int main()
{
    string str;
    cin>>str;
    unsigned long long int i,j,t;
    unsigned long long int count=0,count1=0,val=0,mark=1;
    for(i=(str.length()-1);i>=0;i--)
    {
        //cout<<i<<endl;
        if(str[i]=='a')
        {
        arr[count]=mark;
        count+=1;
        count1=0;
        }
        else if(str[i]=='b'&&count1==0&&count!=0)
        {
            mark=count;
            count1=1;
        }
        if(i==0)
            break;
    }

   for(i=0;i<count;i++)
   {
       if(arr[i]==1){
       val+=arr[i]%(1000000007);}
       else
       {
           val+=1+arr[i]%(1000000007);
       }
   }
   cout<<val;
}


#include<bits/stdc++.h>
using namespace std;
#define m 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000005];

int main()
{
	ll i,l,sum=0,a=0,index=0;
	string str;
	cin>>str;
	l=str.length();
	for(i=0;i<l;i++)
	{
		if(str[i]=='a')
			dp[i+1]=(1+dp[index]+dp[i])%m;
		else if(str[i]=='b')
		{
			dp[i+1]=dp[i];
			index=i;
		}
		else
			dp[i+1]=dp[i];
	}
	cout<<dp[l]<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define m 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000005];

int main()
{
	ll i,l,sum=0,a=0,temp=0,index=0,ans=0;
	string str;
	cin>>str;
	l=str.length();
	for(i=0;i<l;i++)
	{
		if(str[i]=='a')
		{
			a++;
			if(index!=0)
				dp[i]=((a-temp)%m+(((a-temp)%m)*(dp[index]%m))+dp[index])%m;
			else
				dp[i]=a;
		}
		else if(str[i]=='b')
		{
			dp[i]=dp[i-1];
			index=i;
			temp=a;
		}
		else
		{
			dp[i]=dp[i-1];
			temp=a;
		}
	}
	cout<<dp[l-1]<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000005];

int main()
{
	ll i,l,sum=0,a=0,temp=0,index=0,ans=0;
	string str;
	cin>>str;
	l=str.length();
	for(i=0;i<l;i++)
	{
		if(str[i]=='a')
		{
			a++;
			dp[i]=(a-temp)+(a-temp)*dp[index]+dp[index];
		}
		else if(str[i]=='b')
		{
			dp[i]=dp[i-1];
			index=i;
			temp=a;
		}
	}
	cout<<dp[l-1]<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000];

int main()
{
	ll i,l,sum=0;
	string str;
	cin>>str;
	l=str.length();
	for(i=l-1;i>=0;i--)
	{
		if(str[i]=='a')
		{
			if(sum!=0)
			{
				dp['b'-97]+=sum;
				sum=0;
			}
			dp['a'-97]++;
		}
		else if(str[i]=='b')
			sum=dp['a'-97];
	}
	cout<<dp['a'-97]+dp['b'-97]<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000];
int main()
{
	ll i,l;
	string str;
	cin>>str;
	l=str.length();
	for(i=0;i<l;i++)
	{
		if(str[i]=='a')
			dp['a'-97]++;
		else if(str[i]=='b')
			dp['b'-97]+=dp['a'-97];
		else
			dp[str[i]-97]+=dp['b'-97];
	}
	cout<<dp['a'-97]+dp['b'-97]<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000];
int main()
{
	ll i,l;
	string str;
	cin>>str;
	l=str.length();
	for(i=0;i<l;i++)
	{
		if(str[i]=='a')
			dp['a'-97]++;
		else if(str[i]=='b')
			dp['b'-97]+=dp['a'-97];
	}
	cout<<dp['a'-97]+dp['b'-97]<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define m 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000005];

int main()
{
	ll i,l,sum=0,a=0,temp=0,index=0,ans=0;
	string str;
	cin>>str;
	l=str.length();
	for(i=0;i<l;i++)
	{
		if(str[i]=='a')
		{
			a++;
			if(index!=0)
				dp[i]=(a-temp)%m+(((a-temp)%m)*(dp[index]%m))+dp[index];
			else
				dp[i]=a;
			//cout<<a<<" "<<i<<"\n";
		}
		else if(str[i]=='b')
		{
			dp[i]=dp[i-1];
			index=i;
			temp=a;
		}
		else
		{
			dp[i]=dp[i-1];
			temp=a;
		}
	}
	cout<<dp[l-1]<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000];

int main()
{
	ll i,l,sum=0;
	string str;
	cin>>str;
	l=str.length();
	for(i=l-1;i>=0;i--)
	{
		if(str[i]=='a')
		{
			if(sum!=0)
			{
				dp['b'-97]+=sum;
				sum=0;
			}
			else
				dp['a'-97]+=dp['b'-97];
			dp['a'-97]++;
		}
		else if(str[i]=='b')
			sum=dp['a'-97];
	}
	cout<<dp['a'-97]+dp['b'-97]<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug(x) printf("%d\n",x)
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
ll dp[1000005];

int main()
{
	ll i,l,sum=0,a=0,temp=0,index=0,ans=0;
	string str;
	cin>>str;
	l=str.length();
	for(i=0;i<l;i++)
	{
		if(str[i]=='a')
		{
			a++;
			if(index!=0)
				dp[i]=(a-temp)+(a-temp)*dp[index]+dp[index];
			else
				dp[i]=a;
			//cout<<a<<" "<<i<<"\n";
		}
		else if(str[i]=='b')
		{
			dp[i]=dp[i-1];
			index=i;
			temp=a;
		}
		else
		{
			dp[i]=dp[i-1];
			temp=a;
		}
	}
	cout<<dp[l-1]<<"\n";
	return 0;
}


/**
 *   Author: Praveen Ojha
 *   Created: 29 January 2019
 *   Time: 15:39:18
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
#define aint(x) (x).begin(),(x).end()
#define raint(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
inline int mul(int a, int b) {
  return (int) ((long long) a * b % mod);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s="",temp;
    cin>>temp;
   	for(int i=0;i<temp.length();i++)
   	{
   		if(temp[i]=='a' || temp[i]=='b')
   			s+=temp[i];
   	}
   	int n=s.length();
   	vector <int> vv;
   	int cnt=0,ans=1;
   	for(int i=0;i<s.length();i++){
   		if(s[i]=='a')
   		{
   			cnt=(cnt+1)%mod;
   			continue;
   		}
   		if(cnt>0)
   		vv.push_back((cnt+1)%mod);
   		cnt=0;
   	}
   	if(cnt>0)
   	vv.push_back((cnt+1)%mod);
   	// for(int i=0;i<vv.size();i++)
   	// 	cout<<vv[i]<<" ";
   	for(int i=0;i<vv.size();i++){
   		ans=mul(ans,vv[i]);
   	}
   	assert(ans>0);
   	cout<<ans-1<<"\n";
return 0;
}


/**
 *   Author: Praveen Ojha
 *   Created: 29 January 2019
 *   Time: 15:39:18
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s="",temp;
    cin>>temp;
   	for(int i=0;i<temp.length();i++)
   	{
   		if(temp[i]=='a' || temp[i]=='b')
   			s+=temp[i];
   	}
   	int n=s.length();
   	vector <int> vv;
   	int cnt=0,ans=1;
   	for(int i=0;i<s.length();i++){
   		if(s[i]=='a')
   		{
   			cnt=(cnt+1)%mod;
   			continue;
   		}
   		if(cnt>0)
   		vv.push_back(cnt+1);
   		cnt=0;
   	}
   	if(cnt>0)
   	vv.push_back(cnt+1);
   	// for(int i=0;i<vv.size();i++)
   	// 	cout<<vv[i]<<" ";
   	for(int i=0;i<vv.size();i++){
   		ans=(ans*vv[i]%mod)%mod;
   	}
   	assert(ans>0);
   	cout<<ans-1<<"\n";
return 0;
}


/**
 *   Author: Praveen Ojha
 *   Created: 29 January 2019
 *   Time: 15:39:18
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    int dp[n];
    for(int i=0;i<n;i++){
    	if(s[i]=='a')
    		dp[i]=1;
    	else
    		dp[i]=0;
    }
    int dp1[n];
    memset(dp1,0,sizeof dp1);
    for(int i=1;i<n;i++){
    	dp[i]+=dp[i-1];
    }
    int cnt=0,flag=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='a')
    		flag=1;
    	if(s[i]=='b' && flag){
    		cnt++;
    	}
    	else{
    		if(cnt)
    		{
    			dp1[i]++;
    			cnt=0;
    		}
    	}
    }
    cnt=0;
    for(int i=1;i<n;i++)
    	dp1[i]+=dp1[i-1];
    for(int i=0;i<n;i++)
    	cnt+=dp1[i];
    cout<<dp[n-1]+cnt<<"\n";
return 0;
}


/**
 *   Author: Praveen Ojha
 *   Created: 29 January 2019
 *   Time: 15:39:18
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
inline int mul(int a, int b) {
  return (int) ((long long) a * b % mod);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s="",temp;
    cin>>temp;
   	for(ll i=0;i<temp.length();i++)
   	{
   		if(temp[i]=='a' || temp[i]=='b')
   			s+=temp[i];
   	}
   	ll n=s.length();
   	vector <ll> vv;
   	ll cnt=0,ans=1;
   	for(ll i=0;i<s.length();i++){
   		if(s[i]=='a')
   		{
   			cnt=(cnt+1)%mod;
   			continue;
   		}
   		if(cnt>0)
   		vv.push_back((cnt+1)%mod);
   		cnt=0;
   	}
   	if(cnt>0)
   	vv.push_back((cnt+1)%mod);
   	// for(ll i=0;i<vv.size();i++)
   	// 	cout<<vv[i]<<" ";
   	for(ll i=0;i<vv.size();i++){
   		ans=mul(ans,vv[i]);
   	}
   	assert(ans>0);
   	cout<<ans-1<<"\n";
return 0;
}


/**
 *   Author: Praveen Ojha
 *   Created: 29 January 2019
 *   Time: 15:39:18
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    int dp[n];
    for(int i=0;i<n;i++){
    	if(s[i]=='a')
    		dp[i]=1;
    	else
    		dp[i]=0;
    }
    int dp1[n];
    memset(dp1,0,sizeof dp1);
    for(int i=1;i<n;i++){
    	dp[i]=(dp[i]+dp[i-1])%mod;
    }
    ll cnt=0,flag=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='a')
    		flag=1;
    	if(s[i]=='b' && flag){
    		cnt++;
    	}
    	else{
    		if(cnt)
    		{
    			dp1[i]=(dp[i]+1)%mod;
    			cnt=0;
    		}
    	}
    }
    cnt=0;
    for(int i=1;i<n;i++)
    	dp1[i]=(dp1[i]+dp1[i-1])%mod;
    for(int i=0;i<n;i++)
    	cnt+=dp1[i];
    cout<<(dp[n-1]%mod+cnt%mod)%mod<<"\n";
return 0;
}


import java.util.*

fun main() {
    val scanner = Scanner(System.`in`)
//    val scanner = Scanner(File("input.txt"))
    repeat(scanner.nextInt()) {
        val n = scanner.nextInt()
        val m = scanner.nextInt()
        var sum = 0
        for (i in 1..n) {
            sum += scanner.nextInt()
        }
        println(if (sum == m) "YES" else "NO")
    }
}


import java.io.*
import java.util.*
import kotlin.math.*

fun main() {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    val writer = BufferedWriter(OutputStreamWriter(System.out))

    val t = reader.readLine().toInt()

    for (ts in 1..t) {
        val input = reader.readLine().split(" ").map { it.toInt() }
        val n = input[0]
        val m = input[1]
        val ns = reader.readLine().split(" ").map { it.toInt() }
        val nsum = ns.sum()
        if (m == nsum) {
            writer.write("YES\n")
        } else {
            writer.write("NO\n")
        }
    }

    writer.flush()
    reader.close()
    writer.close()
    return
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int t = sc.nextInt();
    for (int tc = 0; tc < t; ++tc) {
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] a = new int[n];
      for (int i = 0; i < a.length; ++i) {
        a[i] = sc.nextInt();
      }

      System.out.println(solve(a, m) ? "YES" : "NO");
    }

    sc.close();
  }

  static boolean solve(int[] a, int m) {
    return Arrays.stream(a).sum() == m;
  }
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.text.DecimalFormat;
import java.math.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            PrintWriter ot=new PrintWriter(System.out);
            int t=Integer.parseInt(br.readLine().trim());
            while(t-->0)
            {
                // int n=Integer.parseInt(br.readLine().trim());
                String ss[]=br.readLine().trim().split(" ");
                int n=Integer.parseInt(ss[0]);
                int m=Integer.parseInt(ss[1]);
                // int a[]=new int[n];
                int sum=0;
                String s[]=br.readLine().trim().split(" ");
                for(int i=0;i<n;i++)
                sum+=Integer.parseInt(s[i]);
                if(sum==m)
                ot.println("YES");
                else
                ot.println("NO");
                // a[i]=Integer.parseInt(s[i]);

            }
            ot.close();
            br.close();

        } catch(Exception e){
            e.printStackTrace();
            return;
        }
    }

}


import java.util.Scanner;

public class CodeforcesDiv2A {

    public static void main(String[] args) {

        int t,y,n,m,sum;
        int[] a;
        Scanner in=new Scanner(System.in);
         t=in.nextInt();
        for(y=1;y<=t;y++){

             n=in.nextInt();
             m=in.nextInt();
             a=new int[n];
            sum=0;
            for(int i=0;i<n;i++){
                a[i]=in.nextInt();

            }

            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    sum+=a[j]/j;
            }

        }
            if(sum<=m)
                System.out.println("YES");
            else
                System.out.println("NO");

     }

}
}


import java.util.Scanner;

public class CodeforcesDiv2A {

    public static void main(String[] args) {

        int t,y,n,m;
        int[] a;
        float sum;
        Scanner in=new Scanner(System.in);
         t=in.nextInt();
        for(y=1;y<=t;y++){

             n=in.nextInt();
             m=in.nextInt();
             a=new int[n];
            sum=0;
            for(int i=0;i<n;i++){
                a[i]=in.nextInt();

            }

            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    sum+=((float)a[j])/((float)(j+1));
            }

        }
            if(sum==m)
                System.out.println("YES");
            else
                System.out.println("NO");

     }

}
}


import java.util.Scanner;

public class CodeforcesDiv2A {

    public static void main(String[] args) {

        int t,y,n,m;
        int[] a;
        float sum;
        Scanner in=new Scanner(System.in);
         t=in.nextInt();
        for(y=1;y<=t;y++){

             n=in.nextInt();
             m=in.nextInt();
             a=new int[n];
            sum=0;
            for(int i=0;i<n;i++){
                a[i]=in.nextInt();

            }

                for(int j=0;j<n;j++){
                    sum+=a[j];

        }
            if(sum==m)
                System.out.println("YES");
            else
                System.out.println("NO");

     }

}
}


import java.util.Scanner;

public class CodeforcesDiv2A {

    public static void main(String[] args) {

        int t,y,n,m,sum;
        int[] a;
        Scanner in=new Scanner(System.in);
         t=in.nextInt();
        for(y=1;y<=t;y++){

             n=in.nextInt();
             m=in.nextInt();
             a=new int[n];
            sum=0;
            for(int i=0;i<n;i++){
                a[i]=in.nextInt();
                sum+=a[i];
            }
            if(sum<m)
                System.out.println("YES");
            else
                System.out.println("NO");

        }
     }

}


import java.util.Scanner;

public class CodeforcesDiv2A {

    public static void main(String[] args) {

        int t,y,n,m,sum;
        int[] a;
        Scanner in=new Scanner(System.in);
         t=in.nextInt();
        for(y=1;y<=t;y++){

             n=in.nextInt();
             m=in.nextInt();
             a=new int[n];
            sum=0;
            for(int i=0;i<n;i++){
                a[i]=in.nextInt();
                sum+=a[i];
            }
            if(sum<=m)
                System.out.println("YES");
            else
                System.out.println("NO");

        }
     }

}


import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.*;
import java.util.LinkedList;
import java.util.logging.SimpleFormatter;

public class solution{

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int t = sc.nextInt() ;
        while (t-- > 0){
            int n = sc.nextInt() ;
            int m = sc.nextInt() ;
            int A[] = sc.readArray(n) ;
            if (Arrays.stream(A).sum() == m)
                System.out.println("YES");
            else
                System.out.println("NO");
        }

    }

    static final Random random=new Random();

    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

}


//https://codeforces.com/contest/1436/problem/A

import java.util.Scanner;

public class P1436A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                sum+=x;
            }
            System.out.println(sum == m ? "YES" : "NO");
        }
    }
}


import java.util.*;
public class cf678_2_1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- > 0) {
			int n = sc.nextInt(),m=sc.nextInt();
			double ans=0.0;
			int a[] = new int[n+1];
			for(int i=1;i<=n;i++) {
				a[i] = sc.nextInt();
				ans += a[i];
			}
			/*Arrays.sort(a);
			for(int i=1;i<=n;i++) {
				for(int j=i;j<=n;j++) {
					ans += (a[j]/(double)j);
					//System.out.println(ans);
				}
			}*/

			if(ans == m) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
		sc.close();
	}

}


import java.util.*;
public class cf678_2_1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- > 0) {
			int n = sc.nextInt(),m=sc.nextInt();
			double ans=0.0;
			int a[] = new int[n+1];
			for(int i=1;i<=n;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a);
			for(int i=1;i<=n;i++) {
				for(int j=i;j<=n;j++) {
					ans += (a[j]/(double)j);
					//System.out.println(ans);
				}
			}

			if(ans == m) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
		sc.close();
	}

}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public final class Main
{
	static boolean[] prime;
	static void sieveOfEratosthenes(int n)
    {
        prime = new boolean[n+1];
        for(int i=0;i<n;i++)
            prime[i] = true;

        for(int p = 2; p*p <=n; p++)
        {
            if(prime[p] == true)
            {
                for(int i = p*2; i <= n; i += p)
                    prime[i] = false;
            }
        }

    }
	static int next(int a) {
		a++;
		while(prime[a] != false) {
			a++;
		}
		return a;
	}
	public static void main (String[] args) throws java.lang.Exception
	{
//		sieveOfEratosthenes(10000);
	    t = s.nextInt();
	    while(t-- > 0){
	    	int n = s.nextInt();
	    	int k = s.nextInt();
	    	int[] a = new int[n];
	    	a = get(a);
	    	long sum = 0;
	    	for(int i = 0;i<n;i++) {
	    		sum += a[i];
	    	}
	    	if(sum == k) {
	    		print("YES", 1);
	    	}else {
	    		print("NO", 1);
	    	}
		}
	}
	/*
		1
		5
		1 2 2 1 3
	 */

	public static int t;

    static class InputReader
	{
		private BufferedReader br;
		private StringTokenizer st;

		public InputReader(InputStream stream)
		{
			br = new BufferedReader(new InputStreamReader(stream));
			st = null;
		}

		public String next()
		{
			while(st == null || !st.hasMoreTokens())
			{
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong(){
		    return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}
	}

	public static InputReader s = new InputReader(System.in);

    public static int[] get(int[] a){
        for(int i = 0;i<a.length;i++){
            a[i] = s.nextInt();
        }
        return a;
    }

    public static void print(Object o, int t){
        System.out.print(o.toString());
        if(t == 1){
            System.out.print("\n");
        }
        if(t == 2){
            System.out.print("\t");
        }
	}
    public static void print(Object[] o, int t){
        System.out.print(Arrays.toString(o));
        if(t == 1){
            System.out.print("\n");
        }
        if(t == 2){
            System.out.print("\t");
        }
	}

}

class Pair
{
	// Return a map entry (key-value pair) from the specified values
	public static <T, U> Map.Entry<T, U> of(T first, U second)
	{
		return new AbstractMap.SimpleEntry<>(first, second);
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public final class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
	    t = s.nextInt();
	    while(t-- > 0){
	    	int n = s.nextInt();
	    	int k = s.nextInt();
	    	int[] a = new int[n];
	    	a = get(a);
	    	Arrays.sort(a);
	    	double sum = 0.0;
	    	if(a[0] == 0) {
	    		print("NO", 1);
	    	}else {
		    	for(int i = 0;i<n;i++) {
		    		for(int j = i;j<n;j++) {
		    			sum += (double)a[j] / (double)(j+1);
		    		}
		    	}
		    	if(sum == (double) k) {
		    		print("YES", 1);
		    	}else {
		    		print("NO", 1);
		    	}
	    	}
		}
	}
	/*
		1
		5
		1 2 2 1 3
	 */

	public static int t;

    static class InputReader
	{
		private BufferedReader br;
		private StringTokenizer st;

		public InputReader(InputStream stream)
		{
			br = new BufferedReader(new InputStreamReader(stream));
			st = null;
		}

		public String next()
		{
			while(st == null || !st.hasMoreTokens())
			{
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong(){
		    return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}
	}

	public static InputReader s = new InputReader(System.in);

    public static int[] get(int[] a){
        for(int i = 0;i<a.length;i++){
            a[i] = s.nextInt();
        }
        return a;
    }

    public static void print(Object o, int t){
        System.out.print(o.toString());
        if(t == 1){
            System.out.print("\n");
        }
        if(t == 2){
            System.out.print("\t");
        }
	}
    public static void print(Object[] o, int t){
        System.out.print(Arrays.toString(o));
        if(t == 1){
            System.out.print("\n");
        }
        if(t == 2){
            System.out.print("\t");
        }
	}

}

class Pair
{
	// Return a map entry (key-value pair) from the specified values
	public static <T, U> Map.Entry<T, U> of(T first, U second)
	{
		return new AbstractMap.SimpleEntry<>(first, second);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class test
{
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
	{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args)
	{
		FastReader scan =new FastReader();
		int t = scan.nextInt();
		while(t-->0){
			int n = scan.nextInt();
			int m = scan.nextInt();
			int c = 0;
			boolean ans = false;
			for(int i=0;i<n;i++){
				c += scan.nextInt();
				if(c == m)ans = true;
			}
			if(ans)System.out.println("YES");
			else System.out.println("NO");

		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class test
{
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
	{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args)
	{
		FastReader scan =new FastReader();
		int t = scan.nextInt();
		while(t-->0){
			int n = scan.nextInt();
			int m = scan.nextInt();
			int c = 0;
			boolean ans = false;
			int[] arr = new int[n];
			for(int i=0;i<n;i++){
				arr[i]  = scan.nextInt();
			}

			for(int i=0;i<n;i++){
				long c = 0;
				for(int j=i;j<n;j++){
					c+= arr[j];
				}
				if(c == m)ans = true;
			}
			if(ans)System.out.println("YES");
			else System.out.println("NO");

		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class test
{
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
	{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args)
	{
		FastReader scan =new FastReader();
		int t = scan.nextInt();
		while(t-->0){
			int n = scan.nextInt();
			int m = scan.nextInt();
			int c = 0;
			boolean ans = false;
			//int[] arr = new int[n];
			for(int i=0;i<n;i++){
				c += scan.nextInt();

			}
			if(c == m)System.out.println("YES");
			else System.out.println("NO");

		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class test
{
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
	{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args)
	{
		FastReader scan =new FastReader();
		int t = scan.nextInt();
		while(t-->0){
			int n = scan.nextInt();
			int m = scan.nextInt();
			//int c = 0;
			boolean ans = false;
			int[] arr = new int[n];
			for(int i=0;i<n;i++){
				arr[i]  = scan.nextInt();
			}

			for(int i=0;i<n;i++){
				long c = 0;
				for(int j=i;j<n;j++){
					c+= arr[j];
				}
				if(c == m)ans = true;
			}
			if(ans)System.out.println("YES");
			else System.out.println("NO");

		}
	}
}


// Working program with FastReader
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    //****************************************************************************************************
    //****************************************************************************************************
    //****************************************************************************************************

    static long factorial(long n)
    {
        if (n == 0)
          return 1;

        return n*factorial(n-1);
    }

    public static void main(String[] args)
    {
        FastReader s =new FastReader();
        int test = s.nextInt();
        long sum=0;

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

            int n = s.nextInt();
            int m = s.nextInt();

            for(int j=0; j<n; j++){
                long input = s.nextLong();
                sum += input;
            }

            if(sum == m){
                System.out.println("YES");
            }
            else{
                System.out.println("NO");
            }

        }

    }
}


// Working program with FastReader
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    //****************************************************************************************************
    //****************************************************************************************************
    //****************************************************************************************************

    static long factorial(long n)
    {
        if (n == 0)
          return 1;

        return n*factorial(n-1);
    }

    public static void main(String[] args)
    {
        FastReader s =new FastReader();
        int test = s.nextInt();

        for(int i=0; i<test; i++){
            long sum=0;
            int n = s.nextInt();
            int m = s.nextInt();

            for(int j=0; j<n; j++){
                long input = s.nextLong();
                sum += input;
            }

            if(sum == m){
                System.out.println("YES");
            }
            else{
                System.out.println("NO");
            }

        }

    }
}


//package codeforces.contest.c1436;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/*
https://codeforces.com/problemset/problem/1436/A
 */
public class TaskA_1436 {

    static void solve() {
        int n = FS.nextInt();
        long m = FS.nextLong();
        long[] a = FS.readArrayL(n);
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }
        if (sum == m) {
            FS.pt.println("YES");
        } else {
            FS.pt.println("NO");
        }
    }

    public static void main(String[] args) {
        int T = FS.nextInt();
        for (int tt = 0; tt < T; tt++) {
            solve();
        }
        FS.pt.close();
    }

    static class FS {
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private static StringTokenizer st = new StringTokenizer("");
        static PrintWriter pt = new PrintWriter(System.out);

        static String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        static int nextInt() {
            return Integer.parseInt(next());
        }

        static int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static int[][] read2Array(int m, int n) {
            int[][] a = new int[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        static long[][] read2ArrayL(int m, int n) {
            long[][] a = new long[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        void printArr(long[] arr) {
            for (long value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static long[] readArrayL(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static void printArr(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void printArrL(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void print2Arr(int[][] arr, int m, int n) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static void print2Arr(long[][] arr, int m, int n) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static List<Long> readListLong(int n) {
            List<Long> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        static List<Integer> readListInt(int n) {
            List<Integer> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }

        static <T> void printList(List<T> list) {
            for (T value : list) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void close() {
            pt.close();
        }

        static long nextLong() {
            return Long.parseLong(next());
        }
    }
}


//package codeforces.contest.c1436;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/*
https://codeforces.com/problemset/problem/1436/A
 */
public class TaskA_1436 {

    static void solve() {
        int n = FS.nextInt();
        long m = FS.nextLong();
        long[] a = FS.readArrayL(n);
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }
        if ((m == 0 && sum == 0) || sum % m == 0) {
            FS.pt.println("YES");
        } else {
            FS.pt.println("NO");
        }
    }

    public static void main(String[] args) {
        int T = FS.nextInt();
        for (int tt = 0; tt < T; tt++) {
            solve();
        }
        FS.pt.close();
    }

    static class FS {
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private static StringTokenizer st = new StringTokenizer("");
        static PrintWriter pt = new PrintWriter(System.out);

        static String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        static int nextInt() {
            return Integer.parseInt(next());
        }

        static int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static int[][] read2Array(int m, int n) {
            int[][] a = new int[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        static long[][] read2ArrayL(int m, int n) {
            long[][] a = new long[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        void printArr(long[] arr) {
            for (long value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static long[] readArrayL(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static void printArr(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void printArrL(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void print2Arr(int[][] arr, int m, int n) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static void print2Arr(long[][] arr, int m, int n) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static List<Long> readListLong(int n) {
            List<Long> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        static List<Integer> readListInt(int n) {
            List<Integer> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }

        static <T> void printList(List<T> list) {
            for (T value : list) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void close() {
            pt.close();
        }

        static long nextLong() {
            return Long.parseLong(next());
        }
    }
}


//package codeforces.contest.c1436;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/*
https://codeforces.com/problemset/problem/1436/A
 */
public class TaskA_1436 {

    static void solve() {
        int n = FS.nextInt();
        long m = FS.nextLong();
        long[] a = FS.readArrayL(n);
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }
        if (sum > 0 && sum % m == 0) {
            FS.pt.println("YES");
        } else {
            FS.pt.println("NO");
        }
    }

    public static void main(String[] args) {
        int T = FS.nextInt();
        for (int tt = 0; tt < T; tt++) {
            solve();
        }
        FS.pt.close();
    }

    static class FS {
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private static StringTokenizer st = new StringTokenizer("");
        static PrintWriter pt = new PrintWriter(System.out);

        static String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        static int nextInt() {
            return Integer.parseInt(next());
        }

        static int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static int[][] read2Array(int m, int n) {
            int[][] a = new int[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        static long[][] read2ArrayL(int m, int n) {
            long[][] a = new long[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        void printArr(long[] arr) {
            for (long value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static long[] readArrayL(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static void printArr(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void printArrL(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void print2Arr(int[][] arr, int m, int n) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static void print2Arr(long[][] arr, int m, int n) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static List<Long> readListLong(int n) {
            List<Long> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        static List<Integer> readListInt(int n) {
            List<Integer> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }

        static <T> void printList(List<T> list) {
            for (T value : list) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void close() {
            pt.close();
        }

        static long nextLong() {
            return Long.parseLong(next());
        }
    }
}


//package codeforces.contest.c1436;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/*
https://codeforces.com/problemset/problem/1436/A
 */
public class TaskA_1436 {

    static void solve() {
        int n = FS.nextInt();
        long m = FS.nextLong();
        long[] a = FS.readArrayL(n);
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }
        if (sum % m == 0) {
            FS.pt.println("YES");
        } else {
            FS.pt.println("NO");
        }
    }

    public static void main(String[] args) {
        int T = FS.nextInt();
        for (int tt = 0; tt < T; tt++) {
            solve();
        }
        FS.pt.close();
    }

    static class FS {
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private static StringTokenizer st = new StringTokenizer("");
        static PrintWriter pt = new PrintWriter(System.out);

        static String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        static int nextInt() {
            return Integer.parseInt(next());
        }

        static int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static int[][] read2Array(int m, int n) {
            int[][] a = new int[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        static long[][] read2ArrayL(int m, int n) {
            long[][] a = new long[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        void printArr(long[] arr) {
            for (long value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static long[] readArrayL(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static void printArr(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void printArrL(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void print2Arr(int[][] arr, int m, int n) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static void print2Arr(long[][] arr, int m, int n) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static List<Long> readListLong(int n) {
            List<Long> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        static List<Integer> readListInt(int n) {
            List<Integer> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }

        static <T> void printList(List<T> list) {
            for (T value : list) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void close() {
            pt.close();
        }

        static long nextLong() {
            return Long.parseLong(next());
        }
    }
}


package com.programming.competitive.trueProblems;

import java.util.*;

public class problem1436a
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        int t = Integer.parseInt(input.nextLine()); //parseInt for primitive

        for(int i = 0; i < t; i++)
        {
            int n = input.nextInt();
            int m = input.nextInt();

            //note that the ai/j will add ai to the overall sum.
            //we can just add the numbers and see if it equals m.

            int sum = 0;
            for(int j = 0; j < n; j++)
            {
                sum += input.nextInt();
            }
            if(sum == m)
                System.out.println("YES");
            else
                System.out.println("NO");
        }

    }
}


//package com.programming.competitive.trueProblems;

import java.util.*;

public class problem1436a
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        int t = Integer.parseInt(input.nextLine()); //parseInt for primitive

        for(int i = 0; i < t; i++)
        {
            int n = input.nextInt();
            int m = input.nextInt();

            //note that the ai/j will add ai to the overall sum.
            //we can just add the numbers and see if it equals m.

            int sum = 0;
            for(int j = 0; j < n; j++)
            {
                sum += input.nextInt();
            }
            if(sum == m)
                System.out.println("YES");
            else
                System.out.println("NO");
        }

    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class Magic
{
	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t-->0)
		{
			int n = s.nextInt();
			int m = s.nextInt();
			int arr[] = new int[n];
			int sum=0;
			for(int i=0;i<n;i++)
			{
				arr[i] = s.nextInt();
				sum+=arr[i];
			}
            if(sum==m)
            {
            	System.out.println("YES");
            }
            else
            {
            	System.out.println("NO");
            }
		}
		System.out.close();
	}
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class Magic
{
	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t-->0)
		{
			int n = s.nextInt();
			int m = s.nextInt();
			int arr[] = new int[n];
			int sum=0;
			for(int i=0;i<n;i++)
			{
				arr[i] = s.nextInt();
				sum+=arr[i];
			}
            if(sum%m==0)
            {
            	System.out.println("YES");
            }
            else
            {
            	System.out.println("NO");
            }
		}
		System.out.close();
	}
}


/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class GFG {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- > 0) {
		    int n = sc.nextInt();
		    int k = sc.nextInt();
		    int ar[] = new int[n];
		    int sum = 0;
		    for(int i = 0; i < n; i++) {
		        ar[i] = sc.nextInt();
		        sum += ar[i];
		    }
		    if(sum == k) {
		        System.out.println("YES");
		    }
		    else {
		        System.out.println("NO");
		    }
		}
	}
}


import java.util.*;

import java.io.*;

public class Prb83 {

    static FastReader sc = new FastReader();

    public static void main(String[] args) {

        int t = sc.nextInt();
        while(t--!=0){
            int n = sc.nextInt();
            int m = sc.nextInt();
            int arr[] = sc.readArray(n);
            int sum = 0;
            for(int i = 0 ; i < n ; i++){
                sum+=arr[i];
            }
            if(sum == m){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }

    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {   try{

            File file =  new File("input.txt");
            br = new BufferedReader(new
            InputStreamReader(new FileInputStream(file)));

        }catch(Exception e){
            br = new BufferedReader(new
            InputStreamReader(System.in));
        }
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }

        int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    }

}