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

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

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

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

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

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

f.z = c
f.y = g
d.t = f
i.t = h
h.z = i
h.y = a
a.z = k
a.y = f
k.t = f
c.t = a
g.z = k
g.y = h
assert k.t.y.y.y.y.z.txt == "c"