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

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

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

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

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

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

c.v = m
c.u = i
c.y = j
c.p = j
j.u = i
m.v = c
i.y = h
i.w = m
h.o = i
g.o = i
assert i.y.o.w.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: D = None
        self.y: B = None
        self.p: B = None
        self.txt = txt

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

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

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

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

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

c.v = m
c.u = i
c.y = j
c.p = j
j.u = i
m.v = c
i.y = h
i.w = m
h.o = i
g.o = i
assert i.y.o.w.v.v.v.txt == "c"