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

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

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

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

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

m.y = k
g.y = b
b.y = k
k.o = b
k.u = b
k.t = g
assert b.y.o.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

m.y = k
g.y = b
b.y = k
k.o = b
k.u = b
k.t = g
assert b.y.o.y.t.txt == "g"