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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: B = None
        self.x: A = None
        self.t: A = None
        self.txt = txt

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

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

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

i.p = f
e.w = i
l.p = e
m.q = f
m.w = e
m.x = i
m.t = i
f.v = e
f.o = l
f.p = m
a.w = e
a.v = l
d.w = e
d.v = l
assert l.p.w.p.o.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: B = None
        self.x: A = None
        self.t: A = None
        self.txt = txt

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

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

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

i.p = f
e.w = i
l.p = e
m.q = f
m.w = e
m.x = i
m.t = i
f.v = e
f.o = l
f.p = m
a.w = e
a.v = l
d.w = e
d.v = l
assert l.p.w.p.o.p.w.p.txt == "f"