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

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

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

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

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

h = A("h")
g = B("g")
c = C("c")
k = D("k")
i = E("i")

h.p = g
h.x = g
h.o = k
g.r = i
g.w = i
g.p = k
c.r = h
c.p = g
k.v = h
k.p = c
i.y = g
i.t = g
assert c.r.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: B = None
        self.o: D = None
        self.txt = txt

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

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

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

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

h = A("h")
g = B("g")
c = C("c")
k = D("k")
i = E("i")

h.p = g
h.x = g
h.o = k
g.r = i
g.w = i
g.p = k
c.r = h
c.p = g
k.v = h
k.p = c
i.y = g
i.t = g
assert c.r.p.r.txt == "i"