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

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

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

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

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

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

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

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

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

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

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

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

l.p = i
c.v = i
c.p = e
i.t = h
e.p = c
h.q = c
h.s = c
h.x = e
assert h.x.p.p.p.txt == "c"