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

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

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

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

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

k = A("k")
h = B("h")
g = C("g")
d = D("d")
f = E("f")

k.q = g
h.o = g
g.u = f
d.v = f
d.x = f
d.o = g
f.v = k
assert f.v.q.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

k = A("k")
h = B("h")
g = C("g")
d = D("d")
f = E("f")

k.q = g
h.o = g
g.u = f
d.v = f
d.x = f
d.o = g
f.v = k
assert f.v.q.u.v.txt == "k"