In such cases, it is useful to work in L and only in L. All elements can be arranged to be there.
Let q be a prime power, the prime will be denoted by p. I will initialize the field L=Fq[w] of characteristic p, of degree six over Fq, containing an element z which generates a subfield L0 of degree three inside L, so that the following tower is realized: L=Fq[w]↑L0=Fq[z]↑K=Fq=Fp[a]↑F=Fp
p, power = 7, 2
q = p^power
F = GF(p)
R.<X> = PolynomialRing(F)
P1power = R.irreducible_element(power)
P3power = R.irreducible_element(3*power)
P6power = R.irreducible_element(6*power)
L.<w> = GF(q^6, modulus=P6power)
z = P3power.roots(ring=L, multiplicities=False)[0]
a = P1power.roots(ring=L, multiplicities=False)[0]
Alternatively:
p, power = 7, 2
q = p^power
K.<a> = GF(q)
R.<X> = PolynomialRing(K)
P3 = R.irreducible_element(3)
P6 = R.irreducible_element(6)
L.<w> = K.extension(P6)
z = P3.roots(ring=L, multiplicities=False)[0]