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

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

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

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

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

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

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

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

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

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

l.s = g
l.u = c
l.q = c
g.y = c
g.x = c
g.z = d
g.w = l
c.r = l
d.z = c
d.v = c
d.o = k
k.z = c
k.v = c
k.o = d
assert k.o.o.o.z.r.txt == "l"