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

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

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

k = A("k")
b = B("b")
h = C("h")
j = C("j")

k.q = j
b.y = k
b.u = k
b.s = j
h.w = b
h.o = b
j.w = b
j.o = b
assert j.o.s.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
h = C("h")
j = C("j")

k.q = j
b.y = k
b.u = k
b.s = j
h.w = b
h.o = b
j.w = b
j.o = b
assert j.o.s.w.s.txt == "j"