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

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

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

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

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

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

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

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

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

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

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

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

f.x = i
f.v = i
f.q = k
e.q = g
e.r = f
i.z = k
k.y = e
k.x = f
m.r = e
m.p = g
m.o = i
g.r = e
g.p = m
g.o = i
assert g.r.r.q.x.x.z.txt == "k"