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

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.q: B = None
        self.txt = txt

m = A("m")
e = B("e")
d = C("d")
j = A("j")
k = C("k")
h = C("h")
n = B("n")
f = A("f")
b = B("b")
l = A("l")

m.r = l
e.u = l
d.p = n
d.s = h
d.q = b
j.r = f
k.p = b
k.s = d
k.q = e
h.p = e
h.s = k
h.q = n
n.u = m
f.r = j
b.u = m
l.r = f
assert k.p.u.r.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.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.q: B = None
        self.txt = txt

m = A("m")
e = B("e")
d = C("d")
j = A("j")
k = C("k")
h = C("h")
n = B("n")
f = A("f")
b = B("b")
l = A("l")

m.r = l
e.u = l
d.p = n
d.s = h
d.q = b
j.r = f
k.p = b
k.s = d
k.q = e
h.p = e
h.s = k
h.q = n
n.u = m
f.r = j
b.u = m
l.r = f
assert k.p.u.r.r.r.r.r.r.r.txt == "j"