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

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: A = None
        self.o: E = None
        self.v: E = None
        self.txt = txt

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

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

c.x = e
c.p = l
j.r = a
l.r = j
l.t = g
e.u = l
e.x = c
e.o = n
e.v = a
a.w = g
a.r = l
n.w = j
n.r = l
g.r = a
assert g.r.w.r.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.p: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: A = None
        self.o: E = None
        self.v: E = None
        self.txt = txt

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

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

c.x = e
c.p = l
j.r = a
l.r = j
l.t = g
e.u = l
e.x = c
e.o = n
e.v = a
a.w = g
a.r = l
n.w = j
n.r = l
g.r = a
assert g.r.w.r.r.t.r.txt == "a"