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

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

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

d = A("d")
c = B("c")
n = C("n")
i = B("i")
m = C("m")
f = B("f")
b = B("b")
a = A("a")
g = B("g")

d.u = a
d.o = a
c.q = d
c.p = g
n.t = c
n.w = f
i.q = d
i.p = b
m.t = g
m.w = b
f.q = d
f.p = c
b.q = d
b.p = c
a.u = d
a.o = d
g.q = a
g.p = b
assert g.q.o.o.o.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: A = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
n = C("n")
i = B("i")
m = C("m")
f = B("f")
b = B("b")
a = A("a")
g = B("g")

d.u = a
d.o = a
c.q = d
c.p = g
n.t = c
n.w = f
i.q = d
i.p = b
m.t = g
m.w = b
f.q = d
f.p = c
b.q = d
b.p = c
a.u = d
a.o = d
g.q = a
g.p = b
assert g.q.o.o.o.u.u.txt == "d"