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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.t: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.t: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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