class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.u: C = None
        self.o: C = None
        self.p: B = None
        self.txt = txt

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

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

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

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

h = A("h")
f = B("f")
i = C("i")
k = D("k")
a = E("a")

h.r = f
h.v = f
h.p = f
h.u = i
h.o = i
f.o = h
f.x = k
f.t = a
i.w = f
k.v = i
a.v = f
a.p = h
a.x = h
assert f.x.v.w.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.u: C = None
        self.o: C = None
        self.p: B = None
        self.txt = txt

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

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

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

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

h = A("h")
f = B("f")
i = C("i")
k = D("k")
a = E("a")

h.r = f
h.v = f
h.p = f
h.u = i
h.o = i
f.o = h
f.x = k
f.t = a
i.w = f
k.v = i
a.v = f
a.p = h
a.x = h
assert f.x.v.w.x.v.txt == "i"