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

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

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

k = A("k")
l = B("l")
j = C("j")
m = B("m")
n = A("n")
h = A("h")
c = C("c")

k.p = c
k.x = c
k.w = h
l.y = n
j.t = l
m.y = k
n.p = j
n.x = j
n.w = h
h.p = c
h.x = j
h.w = k
c.t = l
assert c.t.y.p.t.y.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: C = None
        self.w: A = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
j = C("j")
m = B("m")
n = A("n")
h = A("h")
c = C("c")

k.p = c
k.x = c
k.w = h
l.y = n
j.t = l
m.y = k
n.p = j
n.x = j
n.w = h
h.p = c
h.x = j
h.w = k
c.t = l
assert c.t.y.p.t.y.w.w.txt == "k"