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

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

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.u: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: A = None
        self.u: C = None
        self.v: C = None
        self.txt = txt

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

e.v = i
a.w = i
h.x = c
h.u = c
i.y = e
i.r = e
i.u = h
i.v = h
c.w = i
assert e.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.u: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: A = None
        self.u: C = None
        self.v: C = None
        self.txt = txt

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

e.v = i
a.w = i
h.x = c
h.u = c
i.y = e
i.r = e
i.u = h
i.v = h
c.w = i
assert e.v.y.v.txt == "i"