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

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

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

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

j = A("j")
f = B("f")
a = C("a")
m = D("m")

j.u = f
j.t = m
f.v = a
f.z = j
f.u = j
a.r = j
a.v = j
m.v = j
m.z = j
m.u = a
m.o = a
assert a.v.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: D = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
a = C("a")
m = D("m")

j.u = f
j.t = m
f.v = a
f.z = j
f.u = j
a.r = j
a.v = j
m.v = j
m.z = j
m.u = a
m.o = a
assert a.v.u.z.txt == "j"