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

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

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

d = A("d")
j = B("j")
l = C("l")
n = C("n")

d.p = n
d.q = l
d.v = j
j.w = n
j.r = d
j.z = l
l.u = n
l.s = n
l.w = d
n.u = l
n.s = l
n.w = d
assert n.w.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: C = None
        self.v: B = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
l = C("l")
n = C("n")

d.p = n
d.q = l
d.v = j
j.w = n
j.r = d
j.z = l
l.u = n
l.s = n
l.w = d
n.u = l
n.s = l
n.w = d
assert n.w.q.w.q.txt == "l"