#include #include using namespace std; typedef long long int ll; typedef unsigned int uint; #define STUDENTS 17 #define INF 1234567890 void fill(vector &valid, int state){ if (valid[state]) { return; } valid[state] = true; for (int i=0; i valid(1 << STUDENTS, false); int n; cin >> n; string s; for (int i=0; i> s; uint club = 0; for (char c: s){ club |= 1 << (c - 'a'); } fill(valid, club); } string schedule; cin >> schedule; int m = schedule.size(); vector> next(m, vector(STUDENTS, INF)); for (int i=m-2; i>=0; i--) { for (int j=0; j