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

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

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

b = A("b")
n = B("n")
g = C("g")
k = C("k")
d = B("d")
i = C("i")

b.o = d
b.q = g
n.y = d
n.x = d
n.q = k
g.y = b
g.v = b
g.p = n
k.y = b
k.v = b
k.p = n
d.y = n
d.x = n
d.q = g
i.y = b
i.v = b
i.p = n
assert n.q.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: C = None
        self.txt = txt

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

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

b = A("b")
n = B("n")
g = C("g")
k = C("k")
d = B("d")
i = C("i")

b.o = d
b.q = g
n.y = d
n.x = d
n.q = k
g.y = b
g.v = b
g.p = n
k.y = b
k.v = b
k.p = n
d.y = n
d.x = n
d.q = g
i.y = b
i.v = b
i.p = n
assert n.q.v.q.v.txt == "b"