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

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

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

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

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

h = A("h")
e = B("e")
i = C("i")
f = D("f")
d = E("d")

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

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

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

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

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

h = A("h")
e = B("e")
i = C("i")
f = D("f")
d = E("d")

h.o = d
h.q = e
h.v = i
h.p = f
h.y = f
e.r = d
e.v = i
i.o = f
i.w = d
i.z = h
i.p = h
f.o = h
f.u = i
f.x = e
f.p = d
d.o = e
d.p = e
assert h.v.w.p.v.o.txt == "f"