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

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

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

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: B = None
        self.txt = txt

l = A("l")
d = B("d")
a = C("a")
i = D("i")
b = E("b")
e = F("e")
f = C("f")

l.o = i
d.v = f
a.x = f
a.r = f
i.z = b
b.t = e
b.y = d
e.z = f
e.u = d
f.x = a
f.r = a
assert f.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: B = None
        self.txt = txt

l = A("l")
d = B("d")
a = C("a")
i = D("i")
b = E("b")
e = F("e")
f = C("f")

l.o = i
d.v = f
a.x = f
a.r = f
i.z = b
b.t = e
b.y = d
e.z = f
e.u = d
f.x = a
f.r = a
assert f.r.r.r.r.r.r.txt == "f"