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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: A = None
        self.z: F = None
        self.s: D = None
        self.txt = txt

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

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

i.p = a
i.y = f
i.z = j
j.r = g
j.z = i
g.p = f
a.w = i
f.x = i
f.p = i
f.z = l
f.s = a
l.y = g
h.p = f
assert f.p.y.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.y: E = None
        self.z: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: A = None
        self.z: F = None
        self.s: D = None
        self.txt = txt

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

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

i.p = a
i.y = f
i.z = j
j.r = g
j.z = i
g.p = f
a.w = i
f.x = i
f.p = i
f.z = l
f.s = a
l.y = g
h.p = f
assert f.p.y.p.z.txt == "j"