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

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

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

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

g.w = h
h.t = n
h.w = a
j.v = l
l.w = a
n.t = h
n.w = a
a.t = h
a.w = h
assert a.t.w.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

g.w = h
h.t = n
h.w = a
j.v = l
l.w = a
n.t = h
n.w = a
a.t = h
a.w = h
assert a.t.w.w.t.txt == "n"