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

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

f = A("f")
j = B("j")
h = B("h")
l = A("l")

f.y = l
j.x = h
j.z = l
h.x = j
h.z = l
l.y = f
assert j.z.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

f = A("f")
j = B("j")
h = B("h")
l = A("l")

f.y = l
j.x = h
j.z = l
h.x = j
h.z = l
l.y = f
assert j.z.y.y.txt == "l"