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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: F = None
        self.s: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: B = None
        self.z: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: F = None
        self.s: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: B = None
        self.z: D = None
        self.u: C = None
        self.txt = txt

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

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