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

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

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

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

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

h = A("h")
m = B("m")
c = C("c")
e = D("e")
i = E("i")

h.q = i
h.x = m
m.t = i
m.y = h
c.y = e
c.t = e
e.t = c
i.r = c
assert e.t.y.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: B = None
        self.txt = txt

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

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

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

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

h = A("h")
m = B("m")
c = C("c")
e = D("e")
i = E("i")

h.q = i
h.x = m
m.t = i
m.y = h
c.y = e
c.t = e
e.t = c
i.r = c
assert e.t.y.t.t.txt == "e"