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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: E = None
        self.y: A = None
        self.r: A = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
h = C("h")
e = D("e")
g = E("g")
k = A("k")

c.o = h
c.w = k
l.r = c
h.q = l
h.o = g
h.y = k
h.r = c
e.y = g
g.p = e
k.o = h
k.w = c
assert l.r.w.w.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.w: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: E = None
        self.y: A = None
        self.r: A = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
h = C("h")
e = D("e")
g = E("g")
k = A("k")

c.o = h
c.w = k
l.r = c
h.q = l
h.o = g
h.y = k
h.r = c
e.y = g
g.p = e
k.o = h
k.w = c
assert l.r.w.w.w.o.txt == "h"