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

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

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

f = A("f")
m = B("m")
e = C("e")
g = A("g")
i = A("i")
b = A("b")
c = B("c")
n = C("n")
d = B("d")
l = B("l")

f.y = b
m.s = f
m.x = f
m.t = n
e.r = n
g.y = i
i.y = f
b.y = f
c.s = i
c.x = g
c.t = n
n.r = e
d.s = g
d.x = g
d.t = e
l.s = g
l.x = b
l.t = e
assert b.y.y.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
e = C("e")
g = A("g")
i = A("i")
b = A("b")
c = B("c")
n = C("n")
d = B("d")
l = B("l")

f.y = b
m.s = f
m.x = f
m.t = n
e.r = n
g.y = i
i.y = f
b.y = f
c.s = i
c.x = g
c.t = n
n.r = e
d.s = g
d.x = g
d.t = e
l.s = g
l.x = b
l.t = e
assert b.y.y.y.y.y.y.y.y.y.y.txt == "b"