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

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

j = A("j")
k = B("k")
l = B("l")
e = A("e")
f = A("f")
g = B("g")
i = A("i")
c = A("c")
d = A("d")
a = A("a")

j.q = a
j.z = l
k.t = g
l.t = g
e.q = f
e.z = g
f.q = j
f.z = g
g.t = l
i.q = j
i.z = g
c.q = i
c.z = g
d.q = e
d.z = l
a.q = i
a.z = l
assert f.z.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

j = A("j")
k = B("k")
l = B("l")
e = A("e")
f = A("f")
g = B("g")
i = A("i")
c = A("c")
d = A("d")
a = A("a")

j.q = a
j.z = l
k.t = g
l.t = g
e.q = f
e.z = g
f.q = j
f.z = g
g.t = l
i.q = j
i.z = g
c.q = i
c.z = g
d.q = e
d.z = l
a.q = i
a.z = l
assert f.z.t.t.t.txt == "l"