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

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

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

i = A("i")
d = B("d")
h = C("h")
b = C("b")
f = C("f")
j = B("j")
m = A("m")
l = B("l")
e = A("e")
a = C("a")

i.u = b
i.p = l
d.t = e
d.s = m
d.u = h
h.s = f
b.s = h
f.s = h
j.t = i
j.s = m
j.u = h
m.u = a
m.p = d
l.t = i
l.s = m
l.u = a
e.u = b
e.p = d
a.s = h
assert i.p.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: B = None
        self.txt = txt

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

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

i = A("i")
d = B("d")
h = C("h")
b = C("b")
f = C("f")
j = B("j")
m = A("m")
l = B("l")
e = A("e")
a = C("a")

i.u = b
i.p = l
d.t = e
d.s = m
d.u = h
h.s = f
b.s = h
f.s = h
j.t = i
j.s = m
j.u = h
m.u = a
m.p = d
l.t = i
l.s = m
l.u = a
e.u = b
e.p = d
a.s = h
assert i.p.u.s.txt == "h"