Update 2024
Here I give the Pari/GP-computed results for the cases which could not be solved by @mirkos routine in his comment. I used Pari/GP's "ispseudoprime()" function which allows fast testing to rather large primes
397: 0, 7, 6, 19, 8, 9, 6, 18, 9, 8, 96, 44, 203, 98, 54, 35, 214
827: 0, 8, 10, 15, 9, 13, 9, 14, 9, 7, 22, 15, 35, 37, 68, 49, 27, 10, 53, 145, 201
1009: 0, 6, 11, 12, 24, 8, 25, 29, 54, 15, 78, 49, 6, 12, 140, 11, 317, 71
1061: 0, 8, 8, 21, 10, 13, 5, 21, 25, 7, 32, 10, 13, 6, 5, 14, 18, 20, 9, 27, 12, 41, 33, 14, 11, 52, 25, 37, 52, 14, 23, 141, 35, 79, 78
1069: 0, 8, 9, 6, 18, 9, 8, 96, 44, 203, 98, 54, 35, 214
1091: 0, 8, 14, 5, 8, 34, 18, 7, 5, 7, 8, 25, 34, 19, 26, 58, 28, 8, 8, 21, 10, 13, 5, 21, 25, 7, 32, 10, 13, 6, 5, 14, 18, 20, 9, 27, 12, 41, 33, 14, 11, 52, 25, 37, 52, 14, 23
1123: 0, 10, 6, 19, 8, 9, 6, 18, 9, 8, 96, 44, 203, 98, 54, 35, 214
1129: 0, 12, 6, 5, 14, 18, 20, 9, 27, 12, 41, 33, 14, 11, 52, 25, 37, 52, 14, 23, 141, 35, 79, 78, 64, 149
1193: 0, 7, 9, 21, 17, 6, 5, 17, 33, 37, 54, 217, 14, 138, 25, 8, 12, 113, 18
{listf(a0,maxk=1000)=my(ql=List,cnt=0);
for(k=1,maxk,
if(a0==2,listput(ql,cnt);return(Vec(ql)));
if(ispseudoprime(a0),
a0*=a0;listput(ql,cnt);cnt=0,
a0 \= 2;cnt++);
);
Vec(ql)}
- - - - - - - - - - - -
listf(1193)
End Update