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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: A = None
        self.w: E = None
        self.o: C = None
        self.txt = txt

f = A("f")
i = B("i")
j = C("j")
l = D("l")
a = E("a")
h = F("h")
k = D("k")

f.p = a
i.w = j
i.q = j
j.w = a
j.p = f
j.r = f
j.y = f
l.p = f
a.o = l
a.p = j
a.w = i
h.p = k
h.s = f
h.w = a
h.o = j
k.p = f
assert l.p.p.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: A = None
        self.w: E = None
        self.o: C = None
        self.txt = txt

f = A("f")
i = B("i")
j = C("j")
l = D("l")
a = E("a")
h = F("h")
k = D("k")

f.p = a
i.w = j
i.q = j
j.w = a
j.p = f
j.r = f
j.y = f
l.p = f
a.o = l
a.p = j
a.w = i
h.p = k
h.s = f
h.w = a
h.o = j
k.p = f
assert l.p.p.w.w.txt == "j"