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

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

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

d = A("d")
m = B("m")
e = C("e")
j = A("j")
a = C("a")
c = C("c")
g = C("g")
n = C("n")
k = C("k")

d.x = j
d.o = n
m.q = j
e.t = m
e.x = j
e.w = j
j.x = d
j.o = k
a.t = m
a.x = j
a.w = j
c.t = m
c.x = d
c.w = j
g.t = m
g.x = j
g.w = d
n.t = m
n.x = j
n.w = d
k.t = m
k.x = j
k.w = d
assert a.t.q.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: C = None
        self.txt = txt

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

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

d = A("d")
m = B("m")
e = C("e")
j = A("j")
a = C("a")
c = C("c")
g = C("g")
n = C("n")
k = C("k")

d.x = j
d.o = n
m.q = j
e.t = m
e.x = j
e.w = j
j.x = d
j.o = k
a.t = m
a.x = j
a.w = j
c.t = m
c.x = d
c.w = j
g.t = m
g.x = j
g.w = d
n.t = m
n.x = j
n.w = d
k.t = m
k.x = j
k.w = d
assert a.t.q.o.t.txt == "m"