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

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

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

l = A("l")
f = B("f")
n = C("n")
j = B("j")
m = C("m")
h = C("h")
d = A("d")
c = C("c")

l.p = f
l.q = j
f.x = l
f.s = d
f.u = j
n.w = d
n.r = c
j.x = l
j.s = d
j.u = f
m.w = d
m.r = n
h.w = l
h.r = n
d.p = f
d.q = f
c.w = l
c.r = m
assert h.r.r.r.w.p.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: B = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
n = C("n")
j = B("j")
m = C("m")
h = C("h")
d = A("d")
c = C("c")

l.p = f
l.q = j
f.x = l
f.s = d
f.u = j
n.w = d
n.r = c
j.x = l
j.s = d
j.u = f
m.w = d
m.r = n
h.w = l
h.r = n
d.p = f
d.q = f
c.w = l
c.r = m
assert h.r.r.r.w.p.x.q.txt == "j"