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

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

k = A("k")
g = B("g")
b = A("b")
a = B("a")
i = B("i")
c = B("c")
l = A("l")

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

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

k = A("k")
g = B("g")
b = A("b")
a = B("a")
i = B("i")
c = B("c")
l = A("l")

k.v = i
k.z = l
g.t = k
b.v = a
b.z = l
a.t = l
i.t = l
c.t = b
l.v = c
l.z = b
assert c.t.z.z.v.txt == "a"