#include<bits/stdc++.h>
using namespace std;
int dist[20],par[20],vis[20];
vector<int>adj_list[20];
vector<int>BFS(int st,int dest)
{
vis[st]=1;
par[st]=-1;
dist[st]=0;
queue<int>q;
q.push(st);
vector<int>path;
while(!q.empty())
{
int fr=q.front();
q.pop();
for(int i=0;i<adj_list[fr].size();i++)
{
int adj=adj_list[fr][i];
if(vis[adj]==0)
{
vis[adj]=1;
par[adj]=fr;
dist[adj]=dist[fr]+1;
q.push(adj);
if(adj==dest)
{
int curr=dest;
while(curr!=-1)
{
path.push_back(curr);
curr=par[curr];
}
return path;
}
}
}
}
}
int main()
{
int node,edge,id=0;
cin>>node>>edge;
map<char,int>mp;
map<int,char>rev_mp;
for(int i=1;i<=edge;i++)
{
string e;
cin>>e;
if(mp.find(e[0])==mp.end())
{
mp[e[0]]=id;
rev_mp[id]=e[0];
id++;
}
if(mp.find(e[1])==mp.end())
{
mp[e[1]]=id;
rev_mp[id]=e[1];
id++;
}
adj_list[mp[e[0]]].push_back(mp[e[1]]);
}
int st,dest;
cin>>st>>dest;
vector<int>result;
result=BFS(mp[st],mp[dest]);
cout<<dist[mp[dest]]<<endl;
for(int i=result.size();i>=0;i--)
{
cout<<rev_mp[result[i]]<<" ";
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGRpc3RbMjBdLHBhclsyMF0sdmlzWzIwXTsKdmVjdG9yPGludD5hZGpfbGlzdFsyMF07CnZlY3RvcjxpbnQ+QkZTKGludCBzdCxpbnQgZGVzdCkKewp2aXNbc3RdPTE7CnBhcltzdF09LTE7CmRpc3Rbc3RdPTA7CnF1ZXVlPGludD5xOwpxLnB1c2goc3QpOwp2ZWN0b3I8aW50PnBhdGg7CndoaWxlKCFxLmVtcHR5KCkpCnsKaW50IGZyPXEuZnJvbnQoKTsKcS5wb3AoKTsKZm9yKGludCBpPTA7aTxhZGpfbGlzdFtmcl0uc2l6ZSgpO2krKykKewppbnQgYW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