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

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

c = A("c")
i = B("i")
e = B("e")
l = B("l")
f = B("f")
m = A("m")
k = B("k")

c.r = m
i.z = c
i.x = l
e.z = c
e.x = f
l.z = m
l.x = k
f.z = c
f.x = l
m.r = c
k.z = c
k.x = i
assert i.x.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

c = A("c")
i = B("i")
e = B("e")
l = B("l")
f = B("f")
m = A("m")
k = B("k")

c.r = m
i.z = c
i.x = l
e.z = c
e.x = f
l.z = m
l.x = k
f.z = c
f.x = l
m.r = c
k.z = c
k.x = i
assert i.x.x.z.txt == "c"