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

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

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

l = A("l")
j = B("j")
n = C("n")
e = C("e")
g = B("g")
m = B("m")
d = A("d")

l.y = j
l.q = m
l.z = d
j.x = g
j.r = e
n.o = d
e.o = l
g.x = m
g.r = e
m.x = j
m.r = n
d.y = j
d.q = g
d.z = l
assert l.z.q.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.z: A = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
n = C("n")
e = C("e")
g = B("g")
m = B("m")
d = A("d")

l.y = j
l.q = m
l.z = d
j.x = g
j.r = e
n.o = d
e.o = l
g.x = m
g.r = e
m.x = j
m.r = n
d.y = j
d.q = g
d.z = l
assert l.z.q.x.x.txt == "j"