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

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

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

a = A("a")
f = B("f")
e = C("e")
k = C("k")
b = A("b")
j = B("j")

a.w = j
a.q = j
a.t = e
f.t = a
f.p = k
e.y = a
k.y = b
b.w = j
b.q = f
b.t = k
j.t = a
j.p = e
assert k.y.t.y.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: B = None
        self.t: C = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
e = C("e")
k = C("k")
b = A("b")
j = B("j")

a.w = j
a.q = j
a.t = e
f.t = a
f.p = k
e.y = a
k.y = b
b.w = j
b.q = f
b.t = k
j.t = a
j.p = e
assert k.y.t.y.w.p.txt == "e"