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

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

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

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

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

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

c.o = g
c.r = g
i.s = d
i.q = d
g.o = b
g.x = c
b.s = i
b.y = c
d.w = g
d.o = b
assert d.o.y.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: C = None
        self.txt = txt

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

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

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

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

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

c.o = g
c.r = g
i.s = d
i.q = d
g.o = b
g.x = c
b.s = i
b.y = c
d.w = g
d.o = b
assert d.o.y.r.o.txt == "b"