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

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

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

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

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

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

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

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

m.x = f
f.s = m
f.u = k
f.o = k
e.q = k
e.o = m
e.z = m
k.s = m
k.u = f
k.o = f
assert k.s.x.s.x.txt == "f"