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

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

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

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

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

j.q = f
j.v = l
k.r = l
l.u = j
l.z = f
f.u = k
assert l.z.u.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.v: C = None
        self.txt = txt

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

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

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

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

j.q = f
j.v = l
k.r = l
l.u = j
l.z = f
f.u = k
assert l.z.u.r.z.txt == "f"