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

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

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

l = A("l")
g = B("g")
b = C("b")
j = A("j")

l.y = g
l.o = g
g.x = b
g.s = b
b.w = g
b.z = l
j.y = g
j.o = g
assert b.z.o.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: B = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
b = C("b")
j = A("j")

l.y = g
l.o = g
g.x = b
g.s = b
b.w = g
b.z = l
j.y = g
j.o = g
assert b.z.o.x.z.txt == "l"