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

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

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

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

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

m.s = g
m.o = f
g.t = m
g.s = m
f.x = g
j.y = f
assert g.s.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: C = None
        self.txt = txt

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

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

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

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

m.s = g
m.o = f
g.t = m
g.s = m
f.x = g
j.y = f
assert g.s.o.x.txt == "g"