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

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

i = A("i")
j = B("j")
h = B("h")
l = A("l")
a = B("a")
c = A("c")
m = B("m")
f = B("f")

i.r = l
i.z = m
j.v = i
j.s = f
h.v = c
h.s = j
l.r = i
l.z = f
a.v = l
a.s = j
c.r = l
c.z = a
m.v = c
m.s = a
f.v = i
f.s = j
assert f.s.v.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: B = None
        self.txt = txt

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

i = A("i")
j = B("j")
h = B("h")
l = A("l")
a = B("a")
c = A("c")
m = B("m")
f = B("f")

i.r = l
i.z = m
j.v = i
j.s = f
h.v = c
h.s = j
l.r = i
l.z = f
a.v = l
a.s = j
c.r = l
c.z = a
m.v = c
m.s = a
f.v = i
f.s = j
assert f.s.v.r.z.txt == "f"