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

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

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

a = A("a")
j = B("j")
b = C("b")
n = A("n")
d = C("d")
h = C("h")

a.w = j
a.z = j
a.q = n
j.s = b
j.t = d
b.x = h
b.p = j
n.w = j
n.z = j
n.q = a
d.x = h
d.p = j
h.x = d
h.p = j
assert j.t.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: B = None
        self.q: A = None
        self.txt = txt

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

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

a = A("a")
j = B("j")
b = C("b")
n = A("n")
d = C("d")
h = C("h")

a.w = j
a.z = j
a.q = n
j.s = b
j.t = d
b.x = h
b.p = j
n.w = j
n.z = j
n.q = a
d.x = h
d.p = j
h.x = d
h.p = j
assert j.t.x.x.txt == "d"