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

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

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

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

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

b.x = e
j.v = f
e.z = f
k.r = n
f.v = j
l.x = e
n.r = k
assert f.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

b.x = e
j.v = f
e.z = f
k.r = n
f.v = j
l.x = e
n.r = k
assert f.v.v.v.txt == "j"