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

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

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

n = A("n")
g = B("g")
d = C("d")
f = C("f")
i = C("i")
m = B("m")
b = A("b")
j = A("j")
a = C("a")

n.v = m
g.w = a
g.p = f
d.u = m
d.s = g
f.u = g
f.s = m
i.u = g
i.s = g
m.w = a
m.p = f
b.v = m
j.v = g
a.u = g
a.s = m
assert n.v.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

n = A("n")
g = B("g")
d = C("d")
f = C("f")
i = C("i")
m = B("m")
b = A("b")
j = A("j")
a = C("a")

n.v = m
g.w = a
g.p = f
d.u = m
d.s = g
f.u = g
f.s = m
i.u = g
i.s = g
m.w = a
m.p = f
b.v = m
j.v = g
a.u = g
a.s = m
assert n.v.w.u.txt == "g"