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

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

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

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

g = A("g")
j = B("j")
a = C("a")
m = D("m")

g.s = j
g.y = j
j.o = g
a.v = g
m.z = a
assert a.v.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: B = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
a = C("a")
m = D("m")

g.s = j
g.y = j
j.o = g
a.v = g
m.z = a
assert a.v.s.o.txt == "g"