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

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

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

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

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

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

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

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

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

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

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

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

m.v = k
n.x = b
n.p = i
n.o = m
n.q = g
n.v = k
g.x = c
g.v = k
g.r = k
g.z = i
g.q = i
i.u = g
i.q = m
i.s = n
b.r = g
c.r = g
k.v = m
assert n.p.u.x.r.v.v.v.txt == "k"