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

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

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

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

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

a = A("a")
f = B("f")
m = C("m")
c = D("c")
n = E("n")

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

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

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

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

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

a = A("a")
f = B("f")
m = C("m")
c = D("c")
n = E("n")

a.q = n
a.v = c
f.p = a
m.t = f
m.p = n
m.q = n
m.y = c
c.o = a
c.t = a
c.s = n
c.z = f
n.x = m
n.v = a
n.r = a
assert n.x.q.v.v.txt == "c"