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

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

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

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

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

n = A("n")
f = B("f")
a = C("a")
j = D("j")
g = E("g")
c = C("c")

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

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

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

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

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

n = A("n")
f = B("f")
a = C("a")
j = D("j")
g = E("g")
c = C("c")

n.s = a
n.q = a
n.y = g
f.y = n
a.r = j
j.p = a
j.t = a
j.x = f
g.q = j
c.r = j
assert c.r.p.r.txt == "j"