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

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

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

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

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

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

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

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

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