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

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: G = None
        self.p: E = None
        self.v: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: C = None
        self.w: G = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: G = None
        self.p: E = None
        self.v: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: C = None
        self.w: G = None
        self.txt = txt

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

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

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

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

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