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

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

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

k = A("k")
f = B("f")
j = C("j")
m = B("m")

k.x = f
f.o = j
f.t = j
f.z = m
j.t = k
j.w = k
j.q = k
m.o = j
m.t = j
m.z = f
assert m.z.o.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
j = C("j")
m = B("m")

k.x = f
f.o = j
f.t = j
f.z = m
j.t = k
j.w = k
j.q = k
m.o = j
m.t = j
m.z = f
assert m.z.o.w.x.txt == "f"