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

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

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

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

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

l = A("l")
f = B("f")
d = C("d")
i = D("i")
h = E("h")
e = E("e")

l.r = d
l.x = i
f.p = l
d.s = f
i.p = d
h.t = i
h.r = i
h.q = d
e.t = i
e.r = i
e.q = d
assert e.t.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: D = None
        self.txt = txt

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

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

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

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

l = A("l")
f = B("f")
d = C("d")
i = D("i")
h = E("h")
e = E("e")

l.r = d
l.x = i
f.p = l
d.s = f
i.p = d
h.t = i
h.r = i
h.q = d
e.t = i
e.r = i
e.q = d
assert e.t.p.s.p.txt == "l"