#include<stdio.h> #include<iostream> #include<stack> #include<string.h> using namespace std; #define inf 999999999 #define N 300 struct node { int u,v,w,next; }bian[N*10]; int yong,n,head[N]; void addedge(int u,int v,int w) { bian[yong].v=v; bian[yong].w=w; bian[yong].next=head[u]; head[u]=yong++; } int bellman() { int dis[N],visit[N],count[N]; int cur,i; for(i=0;i<=n;i++) addedge(n+1,i,0); for(i=0;i<=n+1;i++) dis[i]=inf; memset(visit,0,sizeof(visit)); memset(count,0,sizeof(count)); stack<int>q; dis[n+1]=0; q.push(n+1); while(!q.empty()) { cur=q.top(); q.pop(); visit[cur]=0; for(i=head[cur];i!=-1;i=bian[i].next) if(dis[bian[i].v]>dis[cur]+bian[i].w) { dis[bian[i].v]=dis[cur]+bian[i].w; if(!visit[bian[i].v]) { visit[bian[i].v]=1; if(++count[bian[i].v]>n) return 0; q.push(bian[i].v); } } } return 1; } int main() { int i,j,k,m; char s[30]; while(scanf("%d",&n),n) { scanf("%d",&m); yong=0; memset(head,-1,sizeof(head)); while(m--) { scanf("%d%d%s%d",&i,&j,s,&k); if(s[0]=='g') addedge(i+j,i-1,-k-1); if(s[0]=='l') addedge(i-1,i+j,k-1); } if(bellman()) printf("lamentable kingdom "); else printf("successful conspiracy "); } return 0; }