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

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

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

j = A("j")
b = B("b")
g = C("g")
h = A("h")
k = A("k")
l = A("l")
e = B("e")
m = C("m")
f = C("f")
c = B("c")

j.p = c
b.s = h
b.u = h
g.x = m
h.p = b
k.p = b
l.p = c
e.s = k
e.u = k
m.x = f
f.x = g
c.s = h
c.u = j
assert c.s.p.u.p.s.p.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

j = A("j")
b = B("b")
g = C("g")
h = A("h")
k = A("k")
l = A("l")
e = B("e")
m = C("m")
f = C("f")
c = B("c")

j.p = c
b.s = h
b.u = h
g.x = m
h.p = b
k.p = b
l.p = c
e.s = k
e.u = k
m.x = f
f.x = g
c.s = h
c.u = j
assert c.s.p.u.p.s.p.u.p.txt == "b"