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

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

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

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

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

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

c.o = g
i.r = g
i.u = g
j.q = a
j.s = c
g.p = i
g.y = c
g.x = j
a.p = c
a.x = c
a.q = j
a.r = i
assert i.r.p.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

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

c.o = g
i.r = g
i.u = g
j.q = a
j.s = c
g.p = i
g.y = c
g.x = j
a.p = c
a.x = c
a.q = j
a.r = i
assert i.r.p.u.x.txt == "j"