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

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

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

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

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

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

d.r = f
d.s = n
f.y = n
f.w = n
n.u = d
n.v = j
h.u = j
h.o = f
h.y = d
h.v = d
j.v = h
j.o = n
assert h.o.y.v.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: C = None
        self.txt = txt

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

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

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

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

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

d.r = f
d.s = n
f.y = n
f.w = n
n.u = d
n.v = j
h.u = j
h.o = f
h.y = d
h.v = d
j.v = h
j.o = n
assert h.o.y.v.v.u.txt == "j"