class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.r: C = None
        self.o: D = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
a = C("a")
k = D("k")

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

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

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

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

c = A("c")
g = B("g")
a = C("a")
k = D("k")

c.u = g
c.w = g
c.r = a
c.o = k
g.z = a
g.x = c
a.v = g
a.o = g
a.s = k
a.u = c
k.r = c
assert k.r.r.s.txt == "k"