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

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

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

g = A("g")
n = B("n")
j = C("j")
d = C("d")
e = C("e")
l = B("l")
h = C("h")
i = C("i")
a = B("a")
f = C("f")

g.s = n
n.y = f
n.t = a
j.v = i
d.v = e
e.v = f
l.y = d
l.t = a
h.v = i
i.v = d
a.y = d
a.t = n
f.v = i
assert j.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

g = A("g")
n = B("n")
j = C("j")
d = C("d")
e = C("e")
l = B("l")
h = C("h")
i = C("i")
a = B("a")
f = C("f")

g.s = n
n.y = f
n.t = a
j.v = i
d.v = e
e.v = f
l.y = d
l.t = a
h.v = i
i.v = d
a.y = d
a.t = n
f.v = i
assert j.v.v.v.v.txt == "f"