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

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

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

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

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

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

h.p = l
h.x = l
h.s = l
h.t = j
h.q = j
a.x = i
i.y = l
f.q = h
j.p = a
j.s = h
j.r = l
l.q = h
assert h.p.q.p.q.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: D = None
        self.t: E = None
        self.s: D = None
        self.q: E = None
        self.txt = txt

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

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

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

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

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

h.p = l
h.x = l
h.s = l
h.t = j
h.q = j
a.x = i
i.y = l
f.q = h
j.p = a
j.s = h
j.r = l
l.q = h
assert h.p.q.p.q.q.r.txt == "l"