class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: B = None
        self.txt = txt

f = A("f")
j = B("j")
n = B("n")
e = A("e")
l = A("l")
g = B("g")

f.z = l
j.q = l
j.t = g
n.q = f
n.t = g
e.z = l
l.z = e
g.q = f
g.t = n
assert f.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: B = None
        self.txt = txt

f = A("f")
j = B("j")
n = B("n")
e = A("e")
l = A("l")
g = B("g")

f.z = l
j.q = l
j.t = g
n.q = f
n.t = g
e.z = l
l.z = e
g.q = f
g.t = n
assert f.z.z.z.z.z.txt == "l"