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

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

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

a = A("a")
b = B("b")
d = C("d")
l = C("l")
n = B("n")
j = C("j")
k = B("k")
e = A("e")
f = B("f")

a.o = n
a.x = n
b.t = k
b.q = j
b.s = d
d.p = j
d.w = j
l.p = j
l.w = d
n.t = f
n.q = j
n.s = d
j.p = l
j.w = l
k.t = f
k.q = j
k.s = l
e.o = f
e.x = n
f.t = b
f.q = d
f.s = d
assert d.p.w.p.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.txt = txt

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

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

a = A("a")
b = B("b")
d = C("d")
l = C("l")
n = B("n")
j = C("j")
k = B("k")
e = A("e")
f = B("f")

a.o = n
a.x = n
b.t = k
b.q = j
b.s = d
d.p = j
d.w = j
l.p = j
l.w = d
n.t = f
n.q = j
n.s = d
j.p = l
j.w = l
k.t = f
k.q = j
k.s = l
e.o = f
e.x = n
f.t = b
f.q = d
f.s = d
assert d.p.w.p.p.w.txt == "d"