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

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

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

g = A("g")
c = B("c")
b = C("b")
a = B("a")
j = B("j")
l = A("l")
m = A("m")
e = A("e")
n = C("n")

g.u = j
g.p = j
c.u = a
c.s = b
b.w = a
a.u = c
a.s = n
j.u = a
j.s = n
l.u = c
l.p = c
m.u = c
m.p = c
e.u = a
e.p = a
n.w = a
assert g.p.u.s.w.s.w.u.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.p: B = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
b = C("b")
a = B("a")
j = B("j")
l = A("l")
m = A("m")
e = A("e")
n = C("n")

g.u = j
g.p = j
c.u = a
c.s = b
b.w = a
a.u = c
a.s = n
j.u = a
j.s = n
l.u = c
l.p = c
m.u = c
m.p = c
e.u = a
e.p = a
n.w = a
assert g.p.u.s.w.s.w.u.s.w.txt == "a"