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

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

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

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

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

l = A("l")
c = B("c")
k = C("k")
h = D("h")
g = E("g")

l.q = g
c.t = g
c.v = k
c.p = l
k.t = g
k.p = h
k.r = c
k.y = c
k.w = l
h.p = g
h.r = g
g.v = c
g.s = l
assert l.q.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

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

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

l = A("l")
c = B("c")
k = C("k")
h = D("h")
g = E("g")

l.q = g
c.t = g
c.v = k
c.p = l
k.t = g
k.p = h
k.r = c
k.y = c
k.w = l
h.p = g
h.r = g
g.v = c
g.s = l
assert l.q.s.q.s.txt == "l"