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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: A = None
        self.q: B = None
        self.t: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

a = A("a")
h = B("h")
e = C("e")
n = D("n")
g = E("g")
c = F("c")
m = C("m")

a.w = h
a.q = g
h.v = m
h.p = g
h.s = g
h.o = n
e.t = a
n.y = h
n.q = h
n.o = a
n.t = m
g.x = a
c.u = n
c.w = a
c.y = e
m.t = a
assert n.q.v.t.q.x.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: A = None
        self.q: B = None
        self.t: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

a = A("a")
h = B("h")
e = C("e")
n = D("n")
g = E("g")
c = F("c")
m = C("m")

a.w = h
a.q = g
h.v = m
h.p = g
h.s = g
h.o = n
e.t = a
n.y = h
n.q = h
n.o = a
n.t = m
g.x = a
c.u = n
c.w = a
c.y = e
m.t = a
assert n.q.v.t.q.x.w.o.txt == "n"