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

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

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

h = A("h")
k = B("k")
f = C("f")
d = A("d")
e = B("e")
c = C("c")
a = B("a")
n = B("n")
m = B("m")

h.u = f
k.s = n
k.r = h
k.u = m
f.w = m
d.u = c
e.s = k
e.u = k
e.r = h
c.w = k
a.s = k
a.r = d
a.u = e
n.s = a
n.r = h
n.u = m
m.s = k
m.u = k
m.r = d
assert a.u.u.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

h = A("h")
k = B("k")
f = C("f")
d = A("d")
e = B("e")
c = C("c")
a = B("a")
n = B("n")
m = B("m")

h.u = f
k.s = n
k.r = h
k.u = m
f.w = m
d.u = c
e.s = k
e.u = k
e.r = h
c.w = k
a.s = k
a.r = d
a.u = e
n.s = a
n.r = h
n.u = m
m.s = k
m.u = k
m.r = d
assert a.u.u.s.r.txt == "h"