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

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

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

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

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

m.u = e
i.o = m
k.y = e
k.w = e
k.u = g
d.r = g
c.r = g
g.r = d
e.u = m
assert m.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

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

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

m.u = e
i.o = m
k.y = e
k.w = e
k.u = g
d.r = g
c.r = g
g.r = d
e.u = m
assert m.u.u.u.u.u.u.txt == "m"