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

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

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

g = A("g")
k = B("k")
c = C("c")
f = C("f")

g.o = f
k.q = g
k.t = f
k.x = c
c.w = g
c.y = g
c.z = k
f.w = g
f.y = g
f.z = k
assert g.o.y.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
c = C("c")
f = C("f")

g.o = f
k.q = g
k.t = f
k.x = c
c.w = g
c.y = g
c.z = k
f.w = g
f.y = g
f.z = k
assert g.o.y.o.z.txt == "k"