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

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

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

b = A("b")
k = B("k")
n = C("n")
j = B("j")
d = C("d")

b.o = j
b.z = j
b.y = n
k.x = b
k.u = b
k.p = j
n.u = j
n.w = d
n.p = b
j.x = b
j.u = b
j.p = k
d.u = j
d.w = n
d.p = b
assert j.p.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: B = None
        self.y: C = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
n = C("n")
j = B("j")
d = C("d")

b.o = j
b.z = j
b.y = n
k.x = b
k.u = b
k.p = j
n.u = j
n.w = d
n.p = b
j.x = b
j.u = b
j.p = k
d.u = j
d.w = n
d.p = b
assert j.p.x.o.txt == "j"