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

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

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

j = A("j")
c = B("c")
l = C("l")
k = B("k")
n = A("n")

j.r = k
j.y = n
j.p = l
c.s = j
c.o = j
c.w = l
l.y = n
k.s = n
k.w = l
k.o = j
n.r = c
n.y = j
n.p = l
assert c.w.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: A = None
        self.p: C = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
l = C("l")
k = B("k")
n = A("n")

j.r = k
j.y = n
j.p = l
c.s = j
c.o = j
c.w = l
l.y = n
k.s = n
k.w = l
k.o = j
n.r = c
n.y = j
n.p = l
assert c.w.y.y.y.y.txt == "j"