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

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

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

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

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

e = A("e")
h = B("h")
k = C("k")
i = D("i")
j = E("j")

e.y = h
h.x = i
k.t = h
k.u = h
i.r = h
j.r = h
j.q = h
j.x = h
j.p = e
j.t = i
assert j.x.x.r.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

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

e = A("e")
h = B("h")
k = C("k")
i = D("i")
j = E("j")

e.y = h
h.x = i
k.t = h
k.u = h
i.r = h
j.r = h
j.q = h
j.x = h
j.p = e
j.t = i
assert j.x.x.r.x.r.txt == "h"