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

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

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

b = A("b")
h = B("h")
n = C("n")
g = A("g")
e = B("e")
j = C("j")

b.q = j
b.s = g
h.z = e
h.t = e
n.z = g
g.q = j
g.s = b
e.z = h
e.t = h
j.z = g
assert n.z.q.z.q.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: A = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
n = C("n")
g = A("g")
e = B("e")
j = C("j")

b.q = j
b.s = g
h.z = e
h.t = e
n.z = g
g.q = j
g.s = b
e.z = h
e.t = h
j.z = g
assert n.z.q.z.q.z.s.txt == "b"