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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: G = None
        self.z: B = None
        self.q: B = None
        self.w: E = None
        self.r: E = None
        self.txt = txt

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

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

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

a = A("a")
i = B("i")
d = C("d")
n = D("n")
b = E("b")
f = F("f")
e = G("e")

a.z = b
a.w = d
a.q = d
i.o = n
i.q = a
d.o = n
d.u = n
d.q = i
n.u = a
n.o = e
n.z = i
n.q = i
n.w = b
n.r = b
b.r = d
b.y = a
f.u = b
e.q = i
assert n.z.o.q.q.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.w: C = None
        self.q: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: G = None
        self.z: B = None
        self.q: B = None
        self.w: E = None
        self.r: E = None
        self.txt = txt

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

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

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

a = A("a")
i = B("i")
d = C("d")
n = D("n")
b = E("b")
f = F("f")
e = G("e")

a.z = b
a.w = d
a.q = d
i.o = n
i.q = a
d.o = n
d.u = n
d.q = i
n.u = a
n.o = e
n.z = i
n.q = i
n.w = b
n.r = b
b.r = d
b.y = a
f.u = b
e.q = i
assert n.z.o.q.q.q.o.txt == "n"