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

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

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

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

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

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

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