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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: C = None
        self.v: C = 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.w: C = None
        self.txt = txt

j = A("j")
b = B("b")
l = C("l")
m = D("m")
k = A("k")

j.r = l
j.u = l
j.x = k
b.z = l
b.p = l
b.v = l
l.t = b
m.w = l
k.r = l
k.u = l
k.x = j
assert b.v.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: A = None
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: C = None
        self.v: C = 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.w: C = None
        self.txt = txt

j = A("j")
b = B("b")
l = C("l")
m = D("m")
k = A("k")

j.r = l
j.u = l
j.x = k
b.z = l
b.p = l
b.v = l
l.t = b
m.w = l
k.r = l
k.u = l
k.x = j
assert b.v.t.v.txt == "l"