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

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

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

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

l.v = n
j.y = l
j.v = b
b.q = n
n.y = l
n.v = b
assert l.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

l.v = n
j.y = l
j.v = b
b.q = n
n.y = l
n.v = b
assert l.v.y.v.txt == "n"