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

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

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

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

f = A("f")
h = B("h")
c = C("c")
g = D("g")

f.y = c
h.s = f
c.y = h
c.o = h
g.z = h
g.t = f
assert h.s.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
c = C("c")
g = D("g")

f.y = c
h.s = f
c.y = h
c.o = h
g.z = h
g.t = f
assert h.s.y.o.txt == "h"