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

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

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

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

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

f.y = l
f.u = g
f.o = g
g.v = c
c.o = l
c.w = f
i.r = k
k.r = i
l.y = f
l.u = g
l.o = g
assert i.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: B = None
        self.o: B = None
        self.txt = txt

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

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

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

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

f.y = l
f.u = g
f.o = g
g.v = c
c.o = l
c.w = f
i.r = k
k.r = i
l.y = f
l.u = g
l.o = g
assert i.r.r.r.txt == "k"