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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: A = None
        self.txt = txt

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

a.o = g
h.z = i
g.s = i
f.o = h
i.y = a
i.q = a
assert i.q.o.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: A = None
        self.txt = txt

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

a.o = g
h.z = i
g.s = i
f.o = h
i.y = a
i.q = a
assert i.q.o.s.y.txt == "a"