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

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

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

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

b.y = j
b.s = n
b.p = h
h.t = b
h.w = b
h.p = n
n.o = j
n.z = j
j.o = n
j.z = n
assert n.o.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.s: C = None
        self.p: B = None
        self.txt = txt

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

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

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

b.y = j
b.s = n
b.p = h
h.t = b
h.w = b
h.p = n
n.o = j
n.z = j
j.o = n
j.z = n
assert n.o.z.z.z.txt == "n"