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

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

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

k = A("k")
m = B("m")
c = C("c")
f = C("f")
h = C("h")
i = A("i")
g = B("g")
j = C("j")
d = A("d")

k.x = g
m.u = c
m.o = g
m.q = g
c.q = d
c.y = i
f.q = i
f.y = d
h.q = d
h.y = d
i.x = g
g.u = h
g.o = m
g.q = m
j.q = d
j.y = k
d.x = g
assert j.y.x.u.q.x.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

k = A("k")
m = B("m")
c = C("c")
f = C("f")
h = C("h")
i = A("i")
g = B("g")
j = C("j")
d = A("d")

k.x = g
m.u = c
m.o = g
m.q = g
c.q = d
c.y = i
f.q = i
f.y = d
h.q = d
h.y = d
i.x = g
g.u = h
g.o = m
g.q = m
j.q = d
j.y = k
d.x = g
assert j.y.x.u.q.x.u.y.txt == "d"