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

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

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

a = A("a")
e = B("e")
j = C("j")
l = A("l")
k = C("k")
c = C("c")
h = B("h")
d = B("d")
n = A("n")
b = C("b")

a.u = e
e.r = a
e.x = n
j.u = e
j.w = h
l.u = h
k.u = d
k.w = h
c.u = d
c.w = e
h.r = n
h.x = l
d.r = a
d.x = a
n.u = h
b.u = d
b.w = d
assert n.u.r.u.r.u.r.u.x.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

a = A("a")
e = B("e")
j = C("j")
l = A("l")
k = C("k")
c = C("c")
h = B("h")
d = B("d")
n = A("n")
b = C("b")

a.u = e
e.r = a
e.x = n
j.u = e
j.w = h
l.u = h
k.u = d
k.w = h
c.u = d
c.w = e
h.r = n
h.x = l
d.r = a
d.x = a
n.u = h
b.u = d
b.w = d
assert n.u.r.u.r.u.r.u.x.u.r.txt == "n"