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

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

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

h = A("h")
j = B("j")
n = C("n")
c = A("c")
a = B("a")
l = A("l")
f = A("f")

h.x = c
h.s = j
h.r = j
j.u = n
n.x = l
n.p = f
c.x = h
c.s = a
c.r = j
a.u = n
l.x = h
l.s = j
l.r = a
f.x = h
f.s = a
f.r = j
assert l.s.u.p.x.x.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: B = None
        self.r: B = None
        self.txt = txt

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

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

h = A("h")
j = B("j")
n = C("n")
c = A("c")
a = B("a")
l = A("l")
f = A("f")

h.x = c
h.s = j
h.r = j
j.u = n
n.x = l
n.p = f
c.x = h
c.s = a
c.r = j
a.u = n
l.x = h
l.s = j
l.r = a
f.x = h
f.s = a
f.r = j
assert l.s.u.p.x.x.r.u.txt == "n"