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

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

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

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

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

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

f = A("f")
c = B("c")
i = C("i")
e = D("e")
g = E("g")
h = F("h")

f.p = g
f.o = e
f.y = e
f.r = e
c.x = f
c.r = e
i.u = g
e.p = c
e.w = c
e.t = c
e.v = i
e.r = g
g.p = f
h.r = f
h.x = c
h.s = i
h.w = i
h.z = i
assert g.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.o: D = None
        self.y: D = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

f = A("f")
c = B("c")
i = C("i")
e = D("e")
g = E("g")
h = F("h")

f.p = g
f.o = e
f.y = e
f.r = e
c.x = f
c.r = e
i.u = g
e.p = c
e.w = c
e.t = c
e.v = i
e.r = g
g.p = f
h.r = f
h.x = c
h.s = i
h.w = i
h.z = i
assert g.p.p.p.p.p.txt == "f"