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

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

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

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

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

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

h.o = f
h.r = e
e.q = g
e.u = k
e.o = k
e.p = k
k.x = g
k.o = h
k.y = f
g.r = f
g.u = k
f.v = e
f.z = e
assert h.o.v.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.r: B = None
        self.txt = txt

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

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

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

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

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

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