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

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

c = A("c")
j = B("j")
b = B("b")
g = A("g")
h = A("h")
a = A("a")
m = B("m")
k = A("k")
f = B("f")
i = A("i")

c.r = g
c.v = k
j.r = b
b.r = m
g.r = i
g.v = i
h.r = i
h.v = c
a.r = k
a.v = g
m.r = j
k.r = h
k.v = h
f.r = b
i.r = h
i.v = g
assert a.v.r.v.r.v.v.v.v.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: A = None
        self.txt = txt

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

c = A("c")
j = B("j")
b = B("b")
g = A("g")
h = A("h")
a = A("a")
m = B("m")
k = A("k")
f = B("f")
i = A("i")

c.r = g
c.v = k
j.r = b
b.r = m
g.r = i
g.v = i
h.r = i
h.v = c
a.r = k
a.v = g
m.r = j
k.r = h
k.v = h
f.r = b
i.r = h
i.v = g
assert a.v.r.v.r.v.v.v.v.v.r.txt == "i"