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

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

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

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

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

l.z = g
l.s = c
f.r = i
g.y = f
g.s = c
c.q = n
c.u = g
c.v = g
n.r = f
i.r = n
assert c.q.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.s: D = None
        self.txt = txt

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

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

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

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

l.z = g
l.s = c
f.r = i
g.y = f
g.s = c
c.q = n
c.u = g
c.v = g
n.r = f
i.r = n
assert c.q.r.r.txt == "i"