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

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

e.w = n
e.r = n
e.s = g
e.o = b
c.y = e
n.t = h
h.o = n
g.y = e
b.w = n
b.r = n
b.s = g
b.o = e
assert b.w.t.o.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.s: B = None
        self.r: C = None
        self.o: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

e.w = n
e.r = n
e.s = g
e.o = b
c.y = e
n.t = h
h.o = n
g.y = e
b.w = n
b.r = n
b.s = g
b.o = e
assert b.w.t.o.t.o.t.txt == "h"