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

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

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

n = A("n")
d = B("d")
j = C("j")
f = A("f")
l = C("l")
c = B("c")
h = A("h")

n.q = f
n.p = d
n.x = l
d.t = n
j.o = n
j.z = d
f.q = h
f.p = d
f.x = l
l.o = f
l.z = c
c.t = h
h.q = n
h.p = c
h.x = l
assert j.o.x.z.t.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.p: B = None
        self.x: C = None
        self.txt = txt

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

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

n = A("n")
d = B("d")
j = C("j")
f = A("f")
l = C("l")
c = B("c")
h = A("h")

n.q = f
n.p = d
n.x = l
d.t = n
j.o = n
j.z = d
f.q = h
f.p = d
f.x = l
l.o = f
l.z = c
c.t = h
h.q = n
h.p = c
h.x = l
assert j.o.x.z.t.p.t.txt == "h"