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

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

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

g = A("g")
c = B("c")
b = C("b")
n = A("n")
i = A("i")
j = A("j")
e = B("e")

g.q = b
g.w = n
g.x = j
c.z = b
b.x = c
b.o = c
n.q = b
n.w = j
n.x = g
i.q = b
i.w = j
i.x = g
j.q = b
j.w = g
j.x = g
e.z = b
assert j.q.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.w: A = None
        self.x: A = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
b = C("b")
n = A("n")
i = A("i")
j = A("j")
e = B("e")

g.q = b
g.w = n
g.x = j
c.z = b
b.x = c
b.o = c
n.q = b
n.w = j
n.x = g
i.q = b
i.w = j
i.x = g
j.q = b
j.w = g
j.x = g
e.z = b
assert j.q.o.z.txt == "b"