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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.p: G = None
        self.z: G = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
h = C("h")
a = D("a")
n = E("n")
l = F("l")
b = G("b")

m.q = h
d.o = n
d.x = n
d.z = h
h.q = m
h.w = n
a.y = m
a.u = m
a.q = m
a.x = m
a.p = m
n.y = a
n.p = b
n.z = b
l.x = h
l.o = h
b.v = a
b.s = n
b.t = m
assert m.q.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.p: G = None
        self.z: G = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
h = C("h")
a = D("a")
n = E("n")
l = F("l")
b = G("b")

m.q = h
d.o = n
d.x = n
d.z = h
h.q = m
h.w = n
a.y = m
a.u = m
a.q = m
a.x = m
a.p = m
n.y = a
n.p = b
n.z = b
l.x = h
l.o = h
b.v = a
b.s = n
b.t = m
assert m.q.w.y.txt == "a"