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

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

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

e = A("e")
c = B("c")
g = C("g")
a = A("a")
n = C("n")
d = C("d")

e.u = g
e.w = n
c.t = n
c.v = e
g.t = n
g.v = c
g.q = c
a.u = g
a.w = n
n.t = g
n.v = c
n.q = c
d.t = n
d.v = c
d.q = c
assert a.u.v.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.txt = txt

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

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

e = A("e")
c = B("c")
g = C("g")
a = A("a")
n = C("n")
d = C("d")

e.u = g
e.w = n
c.t = n
c.v = e
g.t = n
g.v = c
g.q = c
a.u = g
a.w = n
n.t = g
n.v = c
n.q = c
d.t = n
d.v = c
d.q = c
assert a.u.v.v.w.txt == "n"