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

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.o: A = None
        self.x: B = None
        self.r: D = None
        self.y: D = None
        self.z: E = None
        self.txt = txt

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

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

n.x = b
e.w = n
e.x = m
e.r = m
e.q = k
m.q = k
m.v = n
m.x = e
b.o = n
b.t = c
c.p = k
c.o = n
c.x = e
c.r = b
c.y = b
c.z = g
k.t = m
g.p = k
g.o = n
g.x = e
g.r = b
g.y = b
g.z = c
assert n.x.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.o: A = None
        self.x: B = None
        self.r: D = None
        self.y: D = None
        self.z: E = None
        self.txt = txt

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

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

n.x = b
e.w = n
e.x = m
e.r = m
e.q = k
m.q = k
m.v = n
m.x = e
b.o = n
b.t = c
c.p = k
c.o = n
c.x = e
c.r = b
c.y = b
c.z = g
k.t = m
g.p = k
g.o = n
g.x = e
g.r = b
g.y = b
g.z = c
assert n.x.o.x.txt == "b"