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

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

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

a = A("a")
c = B("c")
g = C("g")
k = A("k")
l = B("l")

a.v = k
a.w = k
a.o = l
c.x = l
c.r = k
c.y = g
g.w = c
g.o = l
g.q = k
k.v = a
k.w = a
k.o = l
l.x = c
l.r = k
l.y = g
assert l.r.w.o.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: A = None
        self.o: B = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
g = C("g")
k = A("k")
l = B("l")

a.v = k
a.w = k
a.o = l
c.x = l
c.r = k
c.y = g
g.w = c
g.o = l
g.q = k
k.v = a
k.w = a
k.o = l
l.x = c
l.r = k
l.y = g
assert l.r.w.o.r.w.txt == "a"