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

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

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

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

l = A("l")
i = B("i")
f = C("f")
h = D("h")

l.u = f
l.t = f
i.z = f
f.u = l
f.q = h
f.x = i
h.x = i
h.z = f
h.s = l
assert h.z.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: C = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
f = C("f")
h = D("h")

l.u = f
l.t = f
i.z = f
f.u = l
f.q = h
f.x = i
h.x = i
h.z = f
h.s = l
assert h.z.u.t.txt == "f"