class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: E = None
        self.z: C = None
        self.p: C = None
        self.s: D = None
        self.txt = txt

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

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

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

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

a = A("a")
d = B("d")
g = C("g")
n = D("n")
m = E("m")
b = A("b")

a.q = b
a.t = m
a.z = g
a.p = g
a.s = n
d.x = m
d.t = b
g.v = a
n.q = m
n.r = m
n.o = g
m.o = n
b.q = a
b.t = m
b.z = g
b.p = g
b.s = n
assert g.v.s.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: E = None
        self.z: C = None
        self.p: C = None
        self.s: D = None
        self.txt = txt

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

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

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

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

a = A("a")
d = B("d")
g = C("g")
n = D("n")
m = E("m")
b = A("b")

a.q = b
a.t = m
a.z = g
a.p = g
a.s = n
d.x = m
d.t = b
g.v = a
n.q = m
n.r = m
n.o = g
m.o = n
b.q = a
b.t = m
b.z = g
b.p = g
b.s = n
assert g.v.s.r.o.txt == "n"