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

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

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

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

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

h = A("h")
j = B("j")
k = C("k")
n = D("n")
d = E("d")
c = D("c")

h.r = d
h.p = d
h.v = n
h.x = j
h.q = k
j.o = h
k.p = h
k.x = d
n.u = d
d.x = h
d.o = n
c.u = d
assert c.u.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.v: D = None
        self.x: B = None
        self.q: C = None
        self.p: E = None
        self.txt = txt

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

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

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

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

h = A("h")
j = B("j")
k = C("k")
n = D("n")
d = E("d")
c = D("c")

h.r = d
h.p = d
h.v = n
h.x = j
h.q = k
j.o = h
k.p = h
k.x = d
n.u = d
d.x = h
d.o = n
c.u = d
assert c.u.x.p.txt == "d"