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

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

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

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

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

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

f.x = a
f.o = a
h.p = e
k.r = a
k.u = f
a.y = h
e.u = h
e.r = h
e.x = h
e.s = k
assert e.r.p.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.o: D = None
        self.txt = txt

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

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

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

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

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

f.x = a
f.o = a
h.p = e
k.r = a
k.u = f
a.y = h
e.u = h
e.r = h
e.x = h
e.s = k
assert e.r.p.u.p.txt == "e"