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

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

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

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

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

g = A("g")
b = B("b")
n = C("n")
j = D("j")
i = E("i")

g.u = b
g.y = j
b.v = j
b.u = g
n.y = j
n.v = g
j.w = g
j.u = b
i.v = n
i.t = b
i.w = j
i.x = j
i.r = g
assert j.w.u.u.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

g = A("g")
b = B("b")
n = C("n")
j = D("j")
i = E("i")

g.u = b
g.y = j
b.v = j
b.u = g
n.y = j
n.v = g
j.w = g
j.u = b
i.v = n
i.t = b
i.w = j
i.x = j
i.r = g
assert j.w.u.u.u.v.txt == "j"