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

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

j = A("j")
e = B("e")
h = B("h")
i = B("i")
a = A("a")
l = B("l")
b = B("b")
m = B("m")
d = A("d")
k = B("k")

j.r = d
e.v = b
e.s = k
h.v = m
h.s = i
i.v = b
i.s = b
a.r = d
l.v = e
l.s = h
b.v = l
b.s = i
m.v = i
m.s = b
d.r = j
k.v = m
k.s = b
assert d.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

j = A("j")
e = B("e")
h = B("h")
i = B("i")
a = A("a")
l = B("l")
b = B("b")
m = B("m")
d = A("d")
k = B("k")

j.r = d
e.v = b
e.s = k
h.v = m
h.s = i
i.v = b
i.s = b
a.r = d
l.v = e
l.s = h
b.v = l
b.s = i
m.v = i
m.s = b
d.r = j
k.v = m
k.s = b
assert d.r.r.r.r.r.r.txt == "d"