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

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

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

d = A("d")
i = B("i")
a = C("a")
l = A("l")
f = C("f")
e = A("e")

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

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

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

d = A("d")
i = B("i")
a = C("a")
l = A("l")
f = C("f")
e = A("e")

d.y = i
d.v = e
i.t = e
a.t = f
a.y = e
l.y = i
l.v = d
f.t = a
f.y = l
e.y = i
e.v = l
assert f.y.v.v.v.txt == "l"