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

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

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

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

c = A("c")
g = B("g")
l = C("l")
a = D("a")
n = C("n")
i = A("i")

c.s = n
c.v = n
c.r = g
c.p = i
g.q = a
g.y = a
l.r = a
a.s = i
a.q = c
a.r = g
n.r = a
i.s = n
i.v = l
i.r = g
i.p = c
assert a.s.s.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: C = None
        self.r: B = None
        self.p: A = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
l = C("l")
a = D("a")
n = C("n")
i = A("i")

c.s = n
c.v = n
c.r = g
c.p = i
g.q = a
g.y = a
l.r = a
a.s = i
a.q = c
a.r = g
n.r = a
i.s = n
i.v = l
i.r = g
i.p = c
assert a.s.s.r.q.txt == "c"