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

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

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

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

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

f = A("f")
e = B("e")
i = C("i")
b = D("b")
c = E("c")

f.x = e
f.s = b
f.o = i
e.q = i
i.o = f
i.y = f
i.x = e
b.x = c
c.p = e
assert i.x.q.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: D = None
        self.o: C = None
        self.txt = txt

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

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

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

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

f = A("f")
e = B("e")
i = C("i")
b = D("b")
c = E("c")

f.x = e
f.s = b
f.o = i
e.q = i
i.o = f
i.y = f
i.x = e
b.x = c
c.p = e
assert i.x.q.o.x.txt == "e"