class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.p: B = None
        self.s: D = 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.u: D = None
        self.txt = txt

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

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

e.v = a
e.p = m
e.s = g
m.s = e
f.u = g
g.o = f
g.x = f
a.v = e
a.p = m
a.s = g
assert f.u.o.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.p: B = None
        self.s: D = 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.u: D = None
        self.txt = txt

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

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

e.v = a
e.p = m
e.s = g
m.s = e
f.u = g
g.o = f
g.x = f
a.v = e
a.p = m
a.s = g
assert f.u.o.u.x.txt == "f"