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

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

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

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

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

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

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

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

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

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

f.y = d
f.x = d
f.v = d
j.v = f
d.o = g
d.t = f
d.s = j
g.u = j
g.y = f
assert d.t.v.t.y.txt == "d"