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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.r: F = None
        self.w: D = None
        self.t: C = None
        self.q: B = None
        self.x: D = None
        self.z: E = None
        self.txt = txt

n = A("n")
d = B("d")
m = C("m")
f = D("f")
g = E("g")
e = F("e")
c = G("c")

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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.r: F = None
        self.w: D = None
        self.t: C = None
        self.q: B = None
        self.x: D = None
        self.z: E = None
        self.txt = txt

n = A("n")
d = B("d")
m = C("m")
f = D("f")
g = E("g")
e = F("e")
c = G("c")

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