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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: C = None
        self.s: B = None
        self.x: C = None
        self.r: D = None
        self.txt = txt

m = A("m")
k = B("k")
a = C("a")
b = D("b")
l = E("l")
g = D("g")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: C = None
        self.s: B = None
        self.x: C = None
        self.r: D = None
        self.txt = txt

m = A("m")
k = B("k")
a = C("a")
b = D("b")
l = E("l")
g = D("g")

m.q = l
m.v = l
m.p = g
k.r = a
a.o = m
a.u = m
a.z = b
b.o = g
b.z = l
l.q = m
l.v = a
l.x = a
l.s = k
l.r = g
g.o = b
g.z = l
assert g.o.o.o.o.o.o.txt == "g"