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

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

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

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

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

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

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

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

b.r = f
n.y = j
n.s = h
n.w = m
g.x = n
g.q = f
f.r = l
l.r = f
h.x = n
h.q = f
j.y = n
j.s = d
j.w = g
d.x = n
d.q = f
m.x = j
m.q = f
assert j.w.x.y.w.q.r.r.txt == "f"