class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: A = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: B = 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.q: C = None
        self.txt = txt

d = A("d")
l = B("l")
g = C("g")
e = D("e")
c = A("c")
i = D("i")
n = B("n")
k = D("k")

d.y = c
d.o = c
d.r = n
l.z = c
l.v = n
g.s = l
e.q = g
c.y = d
c.o = d
c.r = l
i.q = g
n.z = d
n.v = l
k.q = g
assert k.q.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: A = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: B = 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.q: C = None
        self.txt = txt

d = A("d")
l = B("l")
g = C("g")
e = D("e")
c = A("c")
i = D("i")
n = B("n")
k = D("k")

d.y = c
d.o = c
d.r = n
l.z = c
l.v = n
g.s = l
e.q = g
c.y = d
c.o = d
c.r = l
i.q = g
n.z = d
n.v = l
k.q = g
assert k.q.s.z.txt == "c"