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

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

d = A("d")
k = B("k")
i = A("i")
e = B("e")
a = B("a")
f = B("f")

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

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

d = A("d")
k = B("k")
i = A("i")
e = B("e")
a = B("a")
f = B("f")

d.z = f
d.t = a
k.r = a
k.y = i
i.z = e
i.t = e
e.r = a
e.y = i
a.r = f
a.y = i
f.r = k
f.y = i
assert k.y.z.y.z.txt == "e"