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

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

k = A("k")
m = B("m")
c = B("c")
j = A("j")
a = B("a")
e = A("e")
n = B("n")
f = B("f")
b = B("b")

k.x = a
k.r = b
m.v = c
c.v = m
j.x = a
j.r = a
a.v = n
e.x = m
e.r = f
n.v = b
f.v = m
b.v = m
assert b.v.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: B = None
        self.txt = txt

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

k = A("k")
m = B("m")
c = B("c")
j = A("j")
a = B("a")
e = A("e")
n = B("n")
f = B("f")
b = B("b")

k.x = a
k.r = b
m.v = c
c.v = m
j.x = a
j.r = a
a.v = n
e.x = m
e.r = f
n.v = b
f.v = m
b.v = m
assert b.v.v.v.v.v.v.v.v.txt == "c"