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

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

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

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

m = A("m")
f = B("f")
g = C("g")
e = D("e")
k = D("k")

m.o = g
m.x = e
f.t = m
f.w = g
g.v = e
e.y = f
k.y = f
assert e.y.w.v.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: D = None
        self.txt = txt

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

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

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

m = A("m")
f = B("f")
g = C("g")
e = D("e")
k = D("k")

m.o = g
m.x = e
f.t = m
f.w = g
g.v = e
e.y = f
k.y = f
assert e.y.w.v.y.w.txt == "g"