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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: B = None
        self.x: C = None
        self.p: D = None
        self.w: D = None
        self.txt = txt

g = A("g")
m = B("m")
k = C("k")
n = D("n")
c = E("c")
i = A("i")
f = B("f")

g.q = i
g.r = i
g.u = k
g.v = m
m.z = n
m.u = n
m.o = i
m.p = k
m.q = k
k.v = c
k.o = n
k.z = f
n.o = k
c.q = m
c.y = f
c.x = k
c.p = n
c.w = n
i.q = g
i.r = g
i.u = k
i.v = f
f.z = n
f.u = n
f.o = g
f.p = k
f.q = k
assert m.u.o.z.z.o.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: A = None
        self.u: C = None
        self.v: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: B = None
        self.x: C = None
        self.p: D = None
        self.w: D = None
        self.txt = txt

g = A("g")
m = B("m")
k = C("k")
n = D("n")
c = E("c")
i = A("i")
f = B("f")

g.q = i
g.r = i
g.u = k
g.v = m
m.z = n
m.u = n
m.o = i
m.p = k
m.q = k
k.v = c
k.o = n
k.z = f
n.o = k
c.q = m
c.y = f
c.x = k
c.p = n
c.w = n
i.q = g
i.r = g
i.u = k
i.v = f
f.z = n
f.u = n
f.o = g
f.p = k
f.q = k
assert m.u.o.z.z.o.z.u.txt == "n"