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

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

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

l = A("l")
i = B("i")
e = C("e")
d = C("d")
c = A("c")
a = C("a")
g = B("g")
j = B("j")
k = B("k")

l.p = e
l.v = c
l.s = c
i.w = d
e.q = l
d.q = c
c.p = a
c.v = l
c.s = l
a.q = c
g.w = e
j.w = a
k.w = d
assert k.w.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: A = None
        self.s: A = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
e = C("e")
d = C("d")
c = A("c")
a = C("a")
g = B("g")
j = B("j")
k = B("k")

l.p = e
l.v = c
l.s = c
i.w = d
e.q = l
d.q = c
c.p = a
c.v = l
c.s = l
a.q = c
g.w = e
j.w = a
k.w = d
assert k.w.q.p.q.txt == "c"