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

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

c = A("c")
n = B("n")
f = B("f")
h = A("h")
g = B("g")
k = B("k")
l = A("l")

c.y = k
n.z = h
f.z = c
h.y = f
g.z = c
k.z = c
l.y = k
assert c.y.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

c = A("c")
n = B("n")
f = B("f")
h = A("h")
g = B("g")
k = B("k")
l = A("l")

c.y = k
n.z = h
f.z = c
h.y = f
g.z = c
k.z = c
l.y = k
assert c.y.z.y.z.txt == "c"