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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: D = None
        self.s: D = None
        self.x: F = None
        self.q: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: F = None
        self.s: A = None
        self.p: E = None
        self.u: F = None
        self.t: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: F = None
        self.txt = txt

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

m = A("m")
g = B("g")
a = C("a")
k = D("k")
b = E("b")
n = F("n")

m.x = a
g.p = a
g.y = k
g.s = k
g.x = n
g.q = n
a.y = m
a.s = m
a.o = n
a.u = n
a.t = n
a.p = b
k.t = m
k.z = m
k.x = m
k.s = a
k.o = g
k.q = b
b.v = g
b.o = n
n.w = g
assert n.w.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: D = None
        self.s: D = None
        self.x: F = None
        self.q: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: F = None
        self.s: A = None
        self.p: E = None
        self.u: F = None
        self.t: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: F = None
        self.txt = txt

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

m = A("m")
g = B("g")
a = C("a")
k = D("k")
b = E("b")
n = F("n")

m.x = a
g.p = a
g.y = k
g.s = k
g.x = n
g.q = n
a.y = m
a.s = m
a.o = n
a.u = n
a.t = n
a.p = b
k.t = m
k.z = m
k.x = m
k.s = a
k.o = g
k.q = b
b.v = g
b.o = n
n.w = g
assert n.w.q.w.q.txt == "n"