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

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

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

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

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

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

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

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

n.s = j
n.u = l
c.w = j
h.u = f
j.s = n
j.u = i
f.u = h
i.w = a
l.w = n
a.s = n
a.u = l
b.u = f
assert a.s.s.s.u.w.u.w.txt == "n"