class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

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

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

b = A("b")
e = B("e")
a = C("a")
h = D("h")
i = A("i")

b.v = h
b.x = e
b.w = i
e.t = b
e.r = b
e.z = i
e.w = h
a.o = e
a.r = e
a.s = e
h.s = e
i.v = h
i.x = e
i.w = b
assert e.w.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

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

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

b = A("b")
e = B("e")
a = C("a")
h = D("h")
i = A("i")

b.v = h
b.x = e
b.w = i
e.t = b
e.r = b
e.z = i
e.w = h
a.o = e
a.r = e
a.s = e
h.s = e
i.v = h
i.x = e
i.w = b
assert e.w.s.t.txt == "b"