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

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

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

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

b = A("b")
j = B("j")
d = C("d")
f = D("f")
e = A("e")
l = C("l")
g = D("g")

b.u = f
b.o = j
b.t = e
j.z = b
d.y = f
d.p = j
d.s = e
f.r = g
e.u = g
e.o = j
e.t = b
l.y = g
l.p = j
l.s = b
g.r = f
assert d.y.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.o: B = None
        self.t: A = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
d = C("d")
f = D("f")
e = A("e")
l = C("l")
g = D("g")

b.u = f
b.o = j
b.t = e
j.z = b
d.y = f
d.p = j
d.s = e
f.r = g
e.u = g
e.o = j
e.t = b
l.y = g
l.p = j
l.s = b
g.r = f
assert d.y.r.r.r.r.txt == "f"