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

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

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

f = A("f")
i = B("i")
g = C("g")
j = A("j")
l = C("l")
k = B("k")
a = B("a")
b = C("b")

f.s = j
f.w = l
i.r = b
g.p = f
g.t = i
g.y = b
j.s = f
j.w = b
l.p = f
l.t = a
l.y = g
k.r = l
a.r = l
b.p = f
b.t = a
b.y = g
assert f.s.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: C = None
        self.txt = txt

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

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

f = A("f")
i = B("i")
g = C("g")
j = A("j")
l = C("l")
k = B("k")
a = B("a")
b = C("b")

f.s = j
f.w = l
i.r = b
g.p = f
g.t = i
g.y = b
j.s = f
j.w = b
l.p = f
l.t = a
l.y = g
k.r = l
a.r = l
b.p = f
b.t = a
b.y = g
assert f.s.s.w.txt == "l"