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

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

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

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

h.s = k
d.q = n
d.u = c
k.u = l
k.t = h
e.q = n
e.u = c
n.u = l
n.t = h
f.s = n
l.s = n
c.q = n
c.u = e
assert d.q.u.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

h.s = k
d.q = n
d.u = c
k.u = l
k.t = h
e.q = n
e.u = c
n.u = l
n.t = h
f.s = n
l.s = n
c.q = n
c.u = e
assert d.q.u.s.t.txt == "h"