class A:
    def __init__(self, txt: str):
        self.y: G = None
        self.z: B = None
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.w: E = None
        self.x: B = None
        self.y: C = None
        self.r: C = None
        self.z: A = None
        self.u: F = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.w: E = None
        self.x: B = None
        self.y: C = None
        self.r: C = None
        self.z: A = None
        self.u: F = None
        self.txt = txt

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

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