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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: F = None
        self.p: D = None
        self.z: C = None
        self.txt = txt

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

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

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: F = None
        self.p: D = None
        self.z: C = None
        self.txt = txt

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

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

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

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

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

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

a.z = h
a.p = h
a.r = f
a.w = g
c.v = h
c.p = h
c.r = g
c.z = n
n.x = m
n.o = h
n.v = h
n.w = g
n.t = a
n.s = f
h.z = m
f.o = m
g.s = c
g.p = n
m.o = g
m.q = c
assert g.s.r.p.v.z.q.txt == "c"