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

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

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

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

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

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

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

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

h.s = j
f.p = g
j.u = g
j.s = g
n.p = j
l.p = g
d.s = g
c.s = j
a.s = g
g.u = j
g.s = j
assert f.p.s.s.u.s.u.u.s.s.txt == "g"