/*
  AOJ 2135
  Title:Reverse a Road
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

#define max(x,y) (((x)>(y))?(x):(y))
int N,S,T,M;
int from[10001],to[10001];
char road[1001][1001];
int distance[1001];
int dist_all;


void calc_distance(int start,int d)
{
  int i;
  if(distance[start]==-1 || distance[start]>d)
    {
      distance[start]=d;
      if(start==T)
	dist_all=d;
    }
  else
    return;

  for(i=1;i<=1000;i++)
    if(road[start][i])
      calc_distance(i,d+1);
}

solve()
{
  int i,shortcut,max_,max_r,min_road,d1,d2;
  
  for(i=1,max_=1,max_r=0;i<=M;i++)
    {
      d1=distance[from[i]];
      d2=distance[to[i]];
      //printf("%d %d\n",d1,d2);

      if(d1 <= dist_all && d2 <=dist_all)
	{
	  shortcut=d1-d2;
	  if(shortcut>max_)
	    {
	      max_=shortcut;
	      max_r=i;
	    }
	}
    }
  if(max_r)
    printf("%d %d\n",dist_all - max_ + 1, max_r);
  else
    printf("%d 0\n",dist_all);

}
void dump()
{
  int i;
  printf("\n");
  for(i=1;i<=N;i++)
    printf("%d %d\n",i,distance[i]);

}
main()
{
  int i,ret,a,b;
  

  while(scanf("%d",&N)  && (N))
    {
      memset(distance,-1,sizeof(distance));
      memset(road,0,sizeof(road));
      scanf("%d %d",&S,&T);
      //printf("ST%d=>%d\n",S,T);
      scanf("%d",&M);
      for(i=1;i<=M;i++)
	{
	  scanf("%d %d",&a,&b);
	  //printf("%d=>%d|",a,b);
	  from[i]=a;
	  to[i]=b;
	  road[a][b]=1;
	}
      calc_distance(S,0);
      //dump();
      solve();
    }
  return(0);
}