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

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

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

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

e.w = i
e.r = f
e.y = j
f.v = e
a.y = i
d.y = i
h.w = i
h.r = j
h.y = j
i.y = d
j.v = e
assert d.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: B = None
        self.y: B = None
        self.txt = txt

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

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

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

e.w = i
e.r = f
e.y = j
f.v = e
a.y = i
d.y = i
h.w = i
h.r = j
h.y = j
i.y = d
j.v = e
assert d.y.y.y.y.y.y.y.txt == "i"