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

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

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

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

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

a = A("a")
i = B("i")
f = C("f")
n = D("n")
g = E("g")

a.o = g
i.z = n
i.o = f
i.r = a
f.s = i
f.q = n
n.t = a
n.u = a
n.v = a
n.r = g
g.y = a
g.z = a
assert g.z.o.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

a = A("a")
i = B("i")
f = C("f")
n = D("n")
g = E("g")

a.o = g
i.z = n
i.o = f
i.r = a
f.s = i
f.q = n
n.t = a
n.u = a
n.v = a
n.r = g
g.y = a
g.z = a
assert g.z.o.y.o.txt == "g"