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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: C = None
        self.z: E = None
        self.p: B = None
        self.txt = txt

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

k = A("k")
m = B("m")
b = C("b")
n = D("n")
f = E("f")

k.t = f
m.y = b
m.o = b
b.z = f
b.p = k
n.v = k
n.x = b
n.z = f
n.p = m
f.o = n
assert f.o.x.p.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: C = None
        self.z: E = None
        self.p: B = None
        self.txt = txt

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

k = A("k")
m = B("m")
b = C("b")
n = D("n")
f = E("f")

k.t = f
m.y = b
m.o = b
b.z = f
b.p = k
n.v = k
n.x = b
n.z = f
n.p = m
f.o = n
assert f.o.x.p.t.o.txt == "n"