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

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.u: D = None
        self.p: C = None
        self.y: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: D = None
        self.q: E = None
        self.txt = txt

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

c = A("c")
h = B("h")
g = C("g")
j = D("j")
f = E("f")
b = D("b")
i = A("i")

c.r = g
c.y = f
h.q = f
h.y = f
h.u = b
h.p = g
g.r = c
j.u = c
j.s = b
j.q = f
f.x = g
f.p = i
b.u = i
b.s = j
b.q = f
i.r = g
i.y = f
assert h.q.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.u: D = None
        self.p: C = None
        self.y: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: D = None
        self.q: E = None
        self.txt = txt

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

c = A("c")
h = B("h")
g = C("g")
j = D("j")
f = E("f")
b = D("b")
i = A("i")

c.r = g
c.y = f
h.q = f
h.y = f
h.u = b
h.p = g
g.r = c
j.u = c
j.s = b
j.q = f
f.x = g
f.p = i
b.u = i
b.s = j
b.q = f
i.r = g
i.y = f
assert h.q.p.y.p.txt == "i"