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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
m = C("m")
b = D("b")
i = E("i")
g = F("g")
e = G("e")
h = E("h")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
m = C("m")
b = D("b")
i = E("i")
g = F("g")
e = G("e")
h = E("h")

a.q = h
k.z = h
m.z = a
b.y = g
b.x = g
i.v = m
g.w = a
g.u = b
g.x = b
g.r = b
g.s = i
g.y = h
e.v = g
e.z = m
e.r = m
e.u = m
e.q = a
e.o = k
h.v = m
assert k.z.v.z.q.v.txt == "m"