class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: B = None
        self.w: B = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: B = None
        self.w: B = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

c.r = h
h.s = i
h.y = c
h.t = e
e.r = d
i.u = c
i.q = h
i.w = h
i.s = d
i.t = d
m.y = i
d.u = c
d.q = h
d.w = h
d.s = i
d.t = i
assert c.r.s.s.t.txt == "i"