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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: E = None
        self.y: E = None
        self.r: E = None
        self.p: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.o: B = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: B = None
        self.v: A = None
        self.z: B = None
        self.w: D = None
        self.t: F = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: E = None
        self.y: E = None
        self.r: E = None
        self.p: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.o: B = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: B = None
        self.v: A = None
        self.z: B = None
        self.w: D = None
        self.t: F = None
        self.txt = txt

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

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

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