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

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

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

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

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

b = A("b")
e = B("e")
c = C("c")
h = D("h")
g = E("g")
d = B("d")

b.r = d
b.s = d
e.s = d
e.x = h
e.o = g
c.o = e
c.p = d
c.y = h
c.v = b
c.x = b
h.w = b
h.q = c
h.o = c
g.w = h
d.s = e
d.x = h
d.o = g
assert c.v.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

b = A("b")
e = B("e")
c = C("c")
h = D("h")
g = E("g")
d = B("d")

b.r = d
b.s = d
e.s = d
e.x = h
e.o = g
c.o = e
c.p = d
c.y = h
c.v = b
c.x = b
h.w = b
h.q = c
h.o = c
g.w = h
d.s = e
d.x = h
d.o = g
assert c.v.s.o.txt == "g"