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

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

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

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

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

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

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

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

k.o = c
k.v = l
l.o = n
j.q = l
j.y = n
c.o = k
c.v = l
n.q = l
n.y = j
assert l.o.y.q.txt == "l"