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

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

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

f = A("f")
c = B("c")
l = C("l")
i = B("i")
b = A("b")

f.z = l
f.x = b
c.x = f
c.o = i
l.p = c
i.x = b
i.o = c
b.z = l
b.x = f
assert i.o.x.z.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: A = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
l = C("l")
i = B("i")
b = A("b")

f.z = l
f.x = b
c.x = f
c.o = i
l.p = c
i.x = b
i.o = c
b.z = l
b.x = f
assert i.o.x.z.p.x.txt == "f"