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

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

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

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

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

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

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

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

d.p = f
d.q = f
d.x = g
k.q = g
k.o = c
g.o = j
g.u = f
g.w = f
j.o = g
j.u = i
j.w = f
c.q = a
c.o = k
f.p = i
f.q = i
f.x = h
a.o = g
a.u = i
a.w = i
h.o = j
h.u = i
h.w = i
i.p = d
i.x = h
i.q = f
assert j.u.q.q.q.p.p.txt == "d"