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

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

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

b = A("b")
g = B("g")
m = C("m")
j = B("j")
i = B("i")
l = C("l")

b.o = l
b.y = m
g.z = m
g.q = i
m.v = g
m.q = l
j.z = m
j.q = g
i.z = l
i.q = j
l.v = i
l.q = m
assert i.z.q.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: C = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
m = C("m")
j = B("j")
i = B("i")
l = C("l")

b.o = l
b.y = m
g.z = m
g.q = i
m.v = g
m.q = l
j.z = m
j.q = g
i.z = l
i.q = j
l.v = i
l.q = m
assert i.z.q.v.z.txt == "m"