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

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

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

g = A("g")
j = B("j")
f = C("f")
n = B("n")
l = C("l")
e = A("e")
m = A("m")

g.w = j
g.p = j
j.t = e
j.z = n
f.p = l
f.v = j
n.t = g
n.z = j
l.p = f
l.v = n
e.w = n
e.p = n
m.w = n
m.p = n
assert n.z.z.z.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: B = None
        self.txt = txt

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

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

g = A("g")
j = B("j")
f = C("f")
n = B("n")
l = C("l")
e = A("e")
m = A("m")

g.w = j
g.p = j
j.t = e
j.z = n
f.p = l
f.v = j
n.t = g
n.z = j
l.p = f
l.v = n
e.w = n
e.p = n
m.w = n
m.p = n
assert n.z.z.z.t.w.t.txt == "g"