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

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

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

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

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

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

g.t = c
a.z = f
d.z = f
n.t = c
k.z = f
i.z = f
c.t = g
f.t = l
l.t = c
assert a.z.t.t.t.txt == "g"