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

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

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

a = A("a")
i = B("i")
g = C("g")
k = C("k")
l = C("l")
b = A("b")

a.z = b
i.p = k
i.q = b
i.y = g
g.v = b
g.q = b
g.x = i
k.v = a
k.q = a
k.x = i
l.v = b
l.q = b
l.x = i
b.z = a
assert l.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
g = C("g")
k = C("k")
l = C("l")
b = A("b")

a.z = b
i.p = k
i.q = b
i.y = g
g.v = b
g.q = b
g.x = i
k.v = a
k.q = a
k.x = i
l.v = b
l.q = b
l.x = i
b.z = a
assert l.x.p.x.txt == "i"