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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

f = A("f")
j = B("j")
e = C("e")
m = D("m")
l = A("l")
c = B("c")

f.p = e
f.s = e
j.v = c
j.s = c
j.x = c
j.y = f
e.v = c
e.u = c
e.w = j
m.v = e
m.x = e
l.p = e
l.s = e
c.v = j
c.s = j
c.x = j
c.y = f
assert e.u.v.y.p.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

f = A("f")
j = B("j")
e = C("e")
m = D("m")
l = A("l")
c = B("c")

f.p = e
f.s = e
j.v = c
j.s = c
j.x = c
j.y = f
e.v = c
e.u = c
e.w = j
m.v = e
m.x = e
l.p = e
l.s = e
c.v = j
c.s = j
c.x = j
c.y = f
assert e.u.v.y.p.w.y.txt == "f"