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

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

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

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

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

f = A("f")
k = B("k")
d = C("d")
a = D("a")
n = E("n")

f.o = a
k.s = n
k.v = n
k.t = n
k.u = f
k.o = a
d.o = f
a.t = f
a.y = k
n.z = a
n.s = k
n.u = f
assert d.o.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

f = A("f")
k = B("k")
d = C("d")
a = D("a")
n = E("n")

f.o = a
k.s = n
k.v = n
k.t = n
k.u = f
k.o = a
d.o = f
a.t = f
a.y = k
n.z = a
n.s = k
n.u = f
assert d.o.o.t.o.txt == "a"