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

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

k = A("k")
b = B("b")
l = A("l")
d = A("d")
j = A("j")
a = A("a")
m = A("m")
c = A("c")

k.z = b
k.r = b
b.v = d
l.z = b
l.r = b
d.z = b
d.r = b
j.z = b
j.r = b
a.z = b
a.r = b
m.z = b
m.r = b
c.z = b
c.r = b
assert j.z.v.z.v.r.v.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.txt = txt

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

k = A("k")
b = B("b")
l = A("l")
d = A("d")
j = A("j")
a = A("a")
m = A("m")
c = A("c")

k.z = b
k.r = b
b.v = d
l.z = b
l.r = b
d.z = b
d.r = b
j.z = b
j.r = b
a.z = b
a.r = b
m.z = b
m.r = b
c.z = b
c.r = b
assert j.z.v.z.v.r.v.r.v.txt == "d"