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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: E = None
        self.y: F = None
        self.r: G = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: B = None
        self.q: A = None
        self.u: B = None
        self.v: F = None
        self.w: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: E = None
        self.y: F = None
        self.r: G = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: B = None
        self.q: A = None
        self.u: B = None
        self.v: F = None
        self.w: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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