#include <bits/stdc++.h>

using namespace std;

bool dfs(vector<vector<int>>& v,int n,int cur,int x){

    if(cur==n+1) return true;

    bool ans = false;

    for(int i = 0;i<v[x].size();i++){

        ans|=dfs(v, n, cur+1, v[x][i]);

    }

    return ans;

}

int main(){

    vector<vector<int>> v(26);

    string str;

    int n = 0;

    int start = 0;

    vector<int> v1(26,0);

    vector<int> v2(26,0);

    while(cin>>str){

        v[str[0]-'A'].push_back(str.back()-'A');

        v1[str[0]-'A']++;

        v2[str.back()-'A']++;

        start = str[0]-'A';

        n++;

    }

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

        if(v1[i]!=v2[i]){

            cout<<"false"<<endl;

            exit(0);

        }

    }

    if(dfs(v,n, 0, start)){

        cout<<"true"<<endl;

    }else{

        cout<<"false"<<endl;

    }

}

第二题