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

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

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

j = A("j")
a = B("a")
k = C("k")
f = C("f")
h = B("h")
e = A("e")
m = B("m")
b = C("b")

j.s = m
j.u = e
a.x = m
a.u = k
k.y = f
k.r = m
k.q = h
f.y = k
f.r = a
f.q = m
h.x = m
h.u = f
e.s = h
e.u = j
m.x = h
m.u = k
b.y = f
b.r = a
b.q = h
assert b.q.x.x.x.x.x.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: A = None
        self.txt = txt

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

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

j = A("j")
a = B("a")
k = C("k")
f = C("f")
h = B("h")
e = A("e")
m = B("m")
b = C("b")

j.s = m
j.u = e
a.x = m
a.u = k
k.y = f
k.r = m
k.q = h
f.y = k
f.r = a
f.q = m
h.x = m
h.u = f
e.s = h
e.u = j
m.x = h
m.u = k
b.y = f
b.r = a
b.q = h
assert b.q.x.x.x.x.x.x.u.txt == "f"