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

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

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

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

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

f.t = k
f.o = k
f.z = d
f.w = c
c.o = k
c.q = l
k.t = c
d.s = c
l.t = k
l.o = k
l.z = d
l.w = c
assert l.t.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: D = None
        self.o: C = None
        self.w: B = None
        self.txt = txt

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

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

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

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

f.t = k
f.o = k
f.z = d
f.w = c
c.o = k
c.q = l
k.t = c
d.s = c
l.t = k
l.o = k
l.z = d
l.w = c
assert l.t.t.o.txt == "k"