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

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

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

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

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

e.t = i
j.o = e
j.v = e
j.z = f
j.q = l
f.q = d
i.y = d
i.o = f
i.z = e
d.y = i
d.o = f
d.z = e
l.o = e
l.v = e
l.z = f
l.q = j
assert j.z.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

e.t = i
j.o = e
j.v = e
j.z = f
j.q = l
f.q = d
i.y = d
i.o = f
i.z = e
d.y = i
d.o = f
d.z = e
l.o = e
l.v = e
l.z = f
l.q = j
assert j.z.q.o.txt == "f"