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

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

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

i = A("i")
e = B("e")
m = C("m")
d = A("d")
f = B("f")

i.y = m
e.w = m
m.u = f
m.x = e
m.v = d
d.y = m
f.w = m
assert d.y.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

i = A("i")
e = B("e")
m = C("m")
d = A("d")
f = B("f")

i.y = m
e.w = m
m.u = f
m.x = e
m.v = d
d.y = m
f.w = m
assert d.y.v.y.txt == "m"