class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: C = None
        self.x: C = None
        self.txt = txt

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

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

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

b.u = j
b.p = k
b.x = k
i.q = k
k.w = j
k.p = j
j.u = b
j.p = k
j.x = k
assert k.w.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: C = None
        self.x: C = None
        self.txt = txt

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

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

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

b.u = j
b.p = k
b.x = k
i.q = k
k.w = j
k.p = j
j.u = b
j.p = k
j.x = k
assert k.w.x.w.x.txt == "k"