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

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

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

j = A("j")
k = B("k")
n = C("n")
b = C("b")

j.y = k
j.q = k
j.t = n
k.q = b
k.t = n
n.r = b
n.s = b
n.q = b
b.r = n
b.s = n
b.q = n
assert k.q.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.t: C = None
        self.txt = txt

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

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

j = A("j")
k = B("k")
n = C("n")
b = C("b")

j.y = k
j.q = k
j.t = n
k.q = b
k.t = n
n.r = b
n.s = b
n.q = b
b.r = n
b.s = n
b.q = n
assert k.q.s.q.s.txt == "n"