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

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

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

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

c = A("c")
f = B("f")
l = C("l")
j = D("j")

c.u = l
c.z = l
f.r = c
f.o = c
f.s = j
l.t = j
l.q = c
j.t = f
j.y = f
j.z = c
assert l.q.u.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.txt = txt

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

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

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

c = A("c")
f = B("f")
l = C("l")
j = D("j")

c.u = l
c.z = l
f.r = c
f.o = c
f.s = j
l.t = j
l.q = c
j.t = f
j.y = f
j.z = c
assert l.q.u.t.t.txt == "f"