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

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

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

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

m = A("m")
e = B("e")
g = C("g")
k = D("k")

m.y = e
m.x = k
e.v = k
e.u = k
e.r = k
g.o = k
g.p = k
g.s = e
k.o = m
k.u = g
k.z = g
k.x = e
assert m.x.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: D = None
        self.txt = txt

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

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

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

m = A("m")
e = B("e")
g = C("g")
k = D("k")

m.y = e
m.x = k
e.v = k
e.u = k
e.r = k
g.o = k
g.p = k
g.s = e
k.o = m
k.u = g
k.z = g
k.x = e
assert m.x.x.r.txt == "k"