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

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: A = None
        self.q: B = None
        self.o: A = None
        self.txt = txt

l = A("l")
d = B("d")
k = C("k")
g = D("g")

l.z = g
l.s = g
l.v = k
l.y = d
d.s = k
k.t = d
k.p = d
k.u = g
g.w = d
g.q = d
g.v = l
g.o = l
assert l.y.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: C = None
        self.s: D = None
        self.y: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: A = None
        self.q: B = None
        self.o: A = None
        self.txt = txt

l = A("l")
d = B("d")
k = C("k")
g = D("g")

l.z = g
l.s = g
l.v = k
l.y = d
d.s = k
k.t = d
k.p = d
k.u = g
g.w = d
g.q = d
g.v = l
g.o = l
assert l.y.s.t.txt == "d"